From: Andrew Gundersen Date: Mon, 22 Mar 2021 14:53:13 +0000 (-0500) Subject: fixed text input X-Git-Tag: v0.9~13 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=7bb0bda7567180b42ba2cca34ba6944d7b34704a;p=mime-chat fixed text input --- diff --git a/src/components/inputItem/controllers/textCtrl.ts b/src/components/inputItem/controllers/textCtrl.ts index 6a3c22d..ce3a552 100644 --- a/src/components/inputItem/controllers/textCtrl.ts +++ b/src/components/inputItem/controllers/textCtrl.ts @@ -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. diff --git a/src/modules/messages.ts b/src/modules/messages.ts index 7f4d79c..2dcaf00 100644 --- a/src/modules/messages.ts +++ b/src/modules/messages.ts @@ -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 diff --git a/windowState.json b/windowState.json index 9b3dcc5..a9fec30 100644 --- a/windowState.json +++ b/windowState.json @@ -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