Quellcode durchsuchen

Merge pull request #163 from GOWxx/bugfix_send_button_cover_text

fix: send button covering the text in the textarea
Yifei Zhang vor 1 Jahr
Ursprung
Commit
f1b2f895b4
2 geänderte Dateien mit 6 neuen und 1 gelöschten Zeilen
  1. 1 1
      app/components/home.module.scss
  2. 5 0
      app/components/home.tsx

+ 1 - 1
app/components/home.module.scss

@@ -410,7 +410,7 @@
   background-color: var(--white);
   color: var(--black);
   font-family: inherit;
-  padding: 10px 14px;
+  padding: 10px 14px 50px;
   resize: none;
   outline: none;
 }

+ 5 - 0
app/components/home.tsx

@@ -206,6 +206,11 @@ export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean
   // only search prompts when user input is short
   const SEARCH_TEXT_LIMIT = 30;
   const onInput = (text: string) => {
+    const textareaDom = inputRef.current
+    if (textareaDom) {
+      const paddingBottomNum: number = parseInt(window.getComputedStyle(textareaDom).paddingBottom, 10);
+      textareaDom.scrollTop = textareaDom.scrollHeight - textareaDom.offsetHeight + paddingBottomNum;
+    }
     setUserInput(text);
     const n = text.trim().length;
     if (n === 0 || n > SEARCH_TEXT_LIMIT) {