]> Repos - mime-chat/commitdiff
fixed text input
authorAndrew Gundersen <gundersena@xavier.edu>
Mon, 22 Mar 2021 14:53:13 +0000 (09:53 -0500)
committerAndrew Gundersen <gundersena@xavier.edu>
Mon, 22 Mar 2021 14:53:13 +0000 (09:53 -0500)
src/components/inputItem/controllers/textCtrl.ts
src/modules/messages.ts
windowState.json

index 6a3c22dbb4850360e72b244b58a4831c278793df..ce3a552926bb581f2f3c3f5383b88f39cc29992b 100644 (file)
@@ -97,6 +97,14 @@ export default function useTextInputController(elementX: Ref) {
         }
     }
 
+    // Keys that are capable of opening the text input.
+    const hotKeyRange = keyboardNameMap.slice(47, 91)
+    const isHotKey = (key: string) => {
+        if (hotKeyRange.includes(key)) {
+            return true
+        }
+    }
+
     //---Callbacks-----------------------------------------------
 
     const onKeyDown = (e: KeyboardEvent) => {
@@ -104,16 +112,20 @@ export default function useTextInputController(elementX: Ref) {
         
         if (textInput) {
            
-            // First-key handler.
+            // Only runs on firstKey.
             if (firstKey) {
-                if (key == "SPACE") return
+
+                if (!isHotKey(key)) {
+                    return
+                }
+
                 prepInput()
             }
 
             textInput.focus();
 
             // Close input when no text or on ESC.
-            if (textInput.value == "" && !firstKey) {
+            if ((textInput.value == "") && (!firstKey) && (key === "BACK_SPACE")) {
                 clearInput()
                 return
             }
@@ -138,7 +150,7 @@ export default function useTextInputController(elementX: Ref) {
     //-----------------------------------------------------------
 
     // Watch parent position and update side.
-    watch(elementX, (elementX, previous) => {
+    watch(elementX, (elementX, _previous) => {
         const winW = window.innerWidth
 
         // Logic depends on the side we are on.
index 7f4d79ce22828422b3743f75c5dec041bbc469ad..2dcaf00c97da3b9f68b1f6727e0a887229902435 100644 (file)
@@ -83,7 +83,7 @@ export default function useMessages() {
       if (messages.value.size >= 200) {
         const oldest = Array.from(messages.value.keys()).shift();
         messages.value.delete(oldest);
-      };
+      }
 
       // Step 4: Update grouping.
       updateGrouping()
@@ -100,4 +100,4 @@ export default function useMessages() {
       messages,
       updateMessageView
     }
-};
\ No newline at end of file
+}
\ No newline at end of file
index 9b3dcc5516c8d7b5b702dbf4d0f1f396e507672f..a9fec30f53021a24c4bd1b4253b29c3647717231 100644 (file)
@@ -1 +1 @@
-{"w":735,"h":510,"x":1354,"y":513}
\ No newline at end of file
+{"w":735,"h":510,"x":944,"y":489}
\ No newline at end of file