Add auti-resizing input
This commit is contained in:
parent
0074ff0de1
commit
48ce3d96af
|
@ -33,6 +33,11 @@ a.is-disabled {
|
||||||
text-decoration: none !important;
|
text-decoration: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Style the chat input */
|
||||||
|
.chat-input {
|
||||||
|
overflow-y:hidden;
|
||||||
|
}
|
||||||
|
|
||||||
$footer-padding: 3rem 1.5rem;
|
$footer-padding: 3rem 1.5rem;
|
||||||
|
|
||||||
@import "/node_modules/bulma/bulma.sass";
|
@import "/node_modules/bulma/bulma.sass";
|
|
@ -107,7 +107,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav class="level is-mobile chat-header">
|
<nav class="level is-mobile chat-header">
|
||||||
<div class="level-left chatname">
|
<div class="level-left">
|
||||||
<div class="level-item">
|
<div class="level-item">
|
||||||
<p class="subtitle is-5">
|
<p class="subtitle is-5">
|
||||||
{chat.name}
|
{chat.name}
|
||||||
|
@ -184,16 +184,24 @@
|
||||||
<form class="field has-addons has-addons-right" on:submit|preventDefault={send}>
|
<form class="field has-addons has-addons-right" on:submit|preventDefault={send}>
|
||||||
<p class="control is-expanded">
|
<p class="control is-expanded">
|
||||||
<textarea
|
<textarea
|
||||||
class="input is-info is-medium is-focused"
|
class="input is-info is-medium is-focused chat-input"
|
||||||
placeholder="Type your message here..."
|
placeholder="Type your message here..."
|
||||||
rows="1"
|
rows="1"
|
||||||
on:keydown={(e) => {
|
on:keydown={(e) => {
|
||||||
// Only send if Enter is pressed, not Shift+Enter
|
// Only send if Enter is pressed, not Shift+Enter
|
||||||
if (e.key === "Enter" && !e.shiftKey) {
|
if (e.key === "Enter" && !e.shiftKey) {
|
||||||
send();
|
send();
|
||||||
|
// Resize back to auto
|
||||||
|
// @ts-ignore
|
||||||
|
e.target.style.height = "auto";
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
on:input={(e) => {
|
||||||
|
// Resize the textarea to fit the content
|
||||||
|
// @ts-ignore
|
||||||
|
e.target.style.height = e.target.scrollHeight + "px";
|
||||||
|
}}
|
||||||
bind:this={input}
|
bind:this={input}
|
||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue