mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
fix: improve search trigger detection on mobile keyboards
Switch from keydown to beforeinput event for detecting search trigger characters, which works reliably across desktop and mobile virtual keyboards. Allow Shift+Enter to create newlines on mobile devices.
This commit is contained in:
parent
911165b15d
commit
10472bf30a
1 changed files with 9 additions and 8 deletions
|
|
@ -106,23 +106,23 @@
|
|||
}
|
||||
|
||||
if (e.key === "Enter") {
|
||||
if (e.shiftKey) {
|
||||
if (e.shiftKey || Platform.isMobile) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
handleSubmit();
|
||||
}
|
||||
}
|
||||
|
||||
if (isSearchTrigger(e.key)) {
|
||||
e.preventDefault();
|
||||
|
||||
// Detect search triggers on character insertion
|
||||
function handleBeforeInput(e: InputEvent) {
|
||||
// This works reliably on both desktop and mobile (including virtual keyboards)
|
||||
if (e.inputType === "insertText" && e.data && isSearchTrigger(e.data)) {
|
||||
const position = inputService.getCursorPosition(textareaElement);
|
||||
const trigger = fromInput(e.key);
|
||||
|
||||
const trigger = fromInput(e.data);
|
||||
searchStateStore.initializeSearch(trigger, position);
|
||||
|
||||
inputService.insertTextAtCursor(e.key, textareaElement);
|
||||
}
|
||||
// Let the character insert, handleInput() will synchronize the search query
|
||||
}
|
||||
|
||||
async function continueSearch(e: KeyboardEvent) {
|
||||
|
|
@ -287,6 +287,7 @@
|
|||
bind:this={textareaElement}
|
||||
contenteditable="plaintext-only"
|
||||
on:keydown={handleKeydown}
|
||||
on:beforeinput={handleBeforeInput}
|
||||
on:input={handleInput}
|
||||
on:paste={handlePaste}
|
||||
on:copy={handleCopy}
|
||||
|
|
|
|||
Loading…
Reference in a new issue