change textarea auto height method
This commit is contained in:
@@ -829,9 +829,12 @@ export default function ChatBOX(props: {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<textarea
|
<textarea
|
||||||
rows={Math.min(10, (inputMsg.match(/\n/g) || []).length + 2)}
|
|
||||||
value={inputMsg}
|
value={inputMsg}
|
||||||
onChange={(event: any) => setInputMsg(event.target.value)}
|
onChange={(event: any) => {
|
||||||
|
setInputMsg(event.target.value);
|
||||||
|
event.target.style.height = "auto";
|
||||||
|
event.target.style.height = `${event.target.scrollHeight+1}px`;
|
||||||
|
}}
|
||||||
onKeyPress={(event: any) => {
|
onKeyPress={(event: any) => {
|
||||||
console.log(event);
|
console.log(event);
|
||||||
if (event.ctrlKey && event.code === "Enter") {
|
if (event.ctrlKey && event.code === "Enter") {
|
||||||
@@ -840,6 +843,8 @@ export default function ChatBOX(props: {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setInputMsg(event.target.value);
|
setInputMsg(event.target.value);
|
||||||
|
event.target.style.height = "auto";
|
||||||
|
event.target.style.height = `${event.target.scrollHeight+1}px`;
|
||||||
}}
|
}}
|
||||||
className="rounded grow m-1 p-1 border-2 border-gray-400 w-0"
|
className="rounded grow m-1 p-1 border-2 border-gray-400 w-0"
|
||||||
placeholder="Type here..."
|
placeholder="Type here..."
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ const LongInput = (props: {
|
|||||||
onChange={(event: any) => {
|
onChange={(event: any) => {
|
||||||
props.chatStore[props.field] = event.target.value;
|
props.chatStore[props.field] = event.target.value;
|
||||||
props.setChatStore({ ...props.chatStore });
|
props.setChatStore({ ...props.chatStore });
|
||||||
|
event.target.style.height = "auto";
|
||||||
|
event.target.style.height = `${event.target.scrollHeight + 1}px`;
|
||||||
|
}}
|
||||||
|
onKeyPress={(event: any) => {
|
||||||
|
event.target.style.height = "auto";
|
||||||
|
event.target.style.height = `${event.target.scrollHeight + 1}px`;
|
||||||
}}
|
}}
|
||||||
></textarea>
|
></textarea>
|
||||||
</Help>
|
</Help>
|
||||||
|
|||||||
Reference in New Issue
Block a user