mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-02 17:57:57 -05:00
fix: Enter or Escape while typing with an IME saves, submits or closes too early (#35295)
When typing Japanese, Chinese or Korean with an input method (IME), Enter, Space and the arrow keys pick conversion candidates and Escape drops them. Many inputs treated those keys as their own: Escape stopped a running response, threw away a message, cell, rename or comment draft, cleared a search or closed the dialog, drawer, menu or model selector, and Enter or Space saved, submitted, searched, picked a model or added the text while it was still half-typed. Inputs, dialogs and menus that act on these keys now leave keys that belong to the IME alone, the same way chat rename already does. Fixes #35294
This commit is contained in:
1 parent
da69677528
commit
571e4e3b52
43 files changed
+51
-1
No files matched your search
@@ -612,6 +612,7 @@
|
||||
autocomplete="off"
|
||||
bind:value={pattern}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
addPattern();
|
||||
|
||||
@@ -849,6 +849,7 @@
|
||||
bind:value={storeIdInput}
|
||||
on:change={() => addStoreIds(storeIdInput)}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter' || e.key === ',') {
|
||||
e.preventDefault();
|
||||
addStoreIds(storeIdInput);
|
||||
|
||||
@@ -618,6 +618,7 @@
|
||||
placeholder={$i18n.t('Add a model ID')}
|
||||
list={availableModelIds.length ? 'image-model-id-suggestions' : undefined}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
addModelHandler();
|
||||
|
||||
@@ -524,6 +524,7 @@
|
||||
placeholder={$i18n.t('Add a model ID')}
|
||||
list={availableModelIds.length ? 'video-model-id-suggestions' : undefined}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
addModelHandler();
|
||||
|
||||
@@ -480,6 +480,7 @@
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Escape' && query) {
|
||||
query = '';
|
||||
handleSearchInput();
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
bind:value={name}
|
||||
placeholder={$i18n.t('Calendar name')}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') submitHandler();
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -633,6 +633,7 @@
|
||||
bind:value={editedContent}
|
||||
ariaLabel={$i18n.t('Message')}
|
||||
onKeydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Escape') {
|
||||
cancelEditMessage();
|
||||
}
|
||||
|
||||
@@ -254,6 +254,7 @@
|
||||
on:input={(event) =>
|
||||
updateOther(question, (event.currentTarget as HTMLInputElement).value)}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
advance();
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
aria-label={$i18n.t('Ask a question')}
|
||||
bind:value={floatingInputValue}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') {
|
||||
actionHandler(selectedAction?.id);
|
||||
}
|
||||
|
||||
@@ -2417,6 +2417,7 @@
|
||||
<svelte:window
|
||||
on:keydown={(event) => {
|
||||
if (!active) return;
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Escape' && fileAsk) {
|
||||
fileAsk = null;
|
||||
} else handleKeydown(event);
|
||||
@@ -2752,6 +2753,7 @@
|
||||
aria-label={$i18n.t('Search files and contents')}
|
||||
bind:value={searchQuery}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
@@ -3076,6 +3078,7 @@
|
||||
placeholder={$i18n.t('Folder name')}
|
||||
aria-label={$i18n.t('Folder name')}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') submitNewFolder();
|
||||
if (e.key === 'Escape') {
|
||||
creatingFolder = false;
|
||||
@@ -3106,6 +3109,7 @@
|
||||
placeholder={$i18n.t('File name')}
|
||||
aria-label={$i18n.t('File name')}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') submitNewFile();
|
||||
if (e.key === 'Escape') {
|
||||
creatingFile = false;
|
||||
|
||||
@@ -330,6 +330,7 @@
|
||||
}
|
||||
}}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Escape') {
|
||||
pinned = false;
|
||||
hoveredId = null;
|
||||
|
||||
@@ -652,6 +652,7 @@
|
||||
? 'w-full flex-none text-center ring-1 ring-blue-500 rounded'
|
||||
: ''}"
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
submitRename();
|
||||
|
||||
@@ -171,8 +171,9 @@
|
||||
class="min-w-0 flex-1 bg-transparent text-xs text-base-800 outline-hidden dark:text-base-200"
|
||||
aria-label={$i18n.t('Path')}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (selectedFile && e.key !== 'Escape') return;
|
||||
if (e.key === 'Enter' && !e.isComposing) {
|
||||
if (e.key === 'Enter') {
|
||||
goToPath();
|
||||
} else if (e.key === 'Tab' && listFolders) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -198,6 +198,7 @@
|
||||
render();
|
||||
};
|
||||
input.onkeydown = (event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (inline && event.key === 'Enter' && !event.shiftKey) {
|
||||
event.preventDefault();
|
||||
input.blur();
|
||||
|
||||
@@ -290,6 +290,7 @@
|
||||
on:input={autoResize}
|
||||
on:blur={() => cancelEditing(i)}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Escape') cancelEditing(i);
|
||||
}}
|
||||
autofocus
|
||||
|
||||
@@ -2468,6 +2468,7 @@
|
||||
}}
|
||||
on:keydown={async (e) => {
|
||||
e = e.detail.event;
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
|
||||
const isCtrlPressed = e.ctrlKey || e.metaKey; // metaKey is for Cmd key on Mac
|
||||
const suggestionsContainerElement =
|
||||
|
||||
@@ -231,6 +231,7 @@
|
||||
};
|
||||
|
||||
const keydownHandler = (e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Escape') {
|
||||
closeFloatingButtons();
|
||||
}
|
||||
|
||||
@@ -892,6 +892,7 @@
|
||||
if (messagesContainer) messagesContainer.scrollTop = savedScrollTop;
|
||||
}}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Escape') {
|
||||
cancelEditMessage();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
bind:value={inputValue}
|
||||
autocomplete="off"
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') {
|
||||
onRegenerate(inputValue);
|
||||
show = false;
|
||||
|
||||
@@ -325,6 +325,7 @@
|
||||
if (editScrollContainer) editScrollContainer.scrollTop = savedInnerScroll;
|
||||
}}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Escape') {
|
||||
cancelEditMessage();
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
};
|
||||
|
||||
const handleKeydown = (e: KeyboardEvent) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (show && e.key === 'Escape') {
|
||||
if ((e.target as HTMLElement).closest?.('.model-selector-child-menu')) return;
|
||||
e.preventDefault();
|
||||
@@ -954,6 +955,7 @@
|
||||
? `model-option-${selectedModelIdx}`
|
||||
: undefined}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.code === 'Enter') {
|
||||
if (selectedModelIdx >= filteredItems.length) {
|
||||
const target = downloadTargets[selectedModelIdx - filteredItems.length];
|
||||
|
||||
@@ -1505,6 +1505,7 @@
|
||||
if (!search) searchOpen = false;
|
||||
}}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') apply();
|
||||
if (event.key === 'Escape') {
|
||||
search = '';
|
||||
|
||||
@@ -465,6 +465,7 @@
|
||||
class="min-w-0 flex-1 bg-transparent py-0.5 text-xs outline-hidden"
|
||||
placeholder={$i18n.t('Folder name')}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') submitNewFolder();
|
||||
if (e.key === 'Escape') {
|
||||
creatingFolder = false;
|
||||
@@ -484,6 +485,7 @@
|
||||
class="min-w-0 flex-1 bg-transparent py-0.5 text-xs outline-hidden"
|
||||
placeholder={$i18n.t('File name')}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') submitNewFile();
|
||||
if (e.key === 'Escape') {
|
||||
creatingFile = false;
|
||||
|
||||
@@ -398,6 +398,7 @@
|
||||
};
|
||||
|
||||
const searchKeydown = (event: KeyboardEvent) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Escape' && (search || $mobile)) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -305,6 +305,7 @@
|
||||
hide();
|
||||
};
|
||||
const keydown = (event: KeyboardEvent) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if ($commentSelectionDraft) {
|
||||
if (event.key === 'Escape' && !document.getElementById('suggestions-container')) {
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
|
||||
<svelte:window
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Escape' && !modal) view = null;
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
/>
|
||||
<svelte:window
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Escape') {
|
||||
if (
|
||||
($showTabs === 'comments' || typeof $showTabs === 'object') &&
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
};
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (
|
||||
event.key === 'Escape' ||
|
||||
($settings?.keyboardShortcuts !== false && matchKeybinding(event) === Shortcut.CLOSE_MODAL)
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
let focusTrap: FocusTrap.FocusTrap | null = null;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (
|
||||
(event.key === 'Escape' ||
|
||||
($settings?.keyboardShortcuts !== false &&
|
||||
|
||||
@@ -358,6 +358,7 @@
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Escape' && show) {
|
||||
closeDropdown();
|
||||
}
|
||||
|
||||
@@ -757,6 +757,7 @@
|
||||
aria-label={t('Find in sheet')}
|
||||
placeholder={t('Find in sheet')}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
findNext(event.shiftKey ? -1 : 1);
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
};
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (
|
||||
(event.key === 'Escape' ||
|
||||
($settings?.keyboardShortcuts !== false &&
|
||||
|
||||
@@ -117,6 +117,7 @@
|
||||
positionPopup();
|
||||
}}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
||||
if (filteredSuggestionTags.length === 0) return;
|
||||
event.preventDefault();
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
aria-label={$i18n.t('Add a tag')}
|
||||
list="tagOptions"
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
event.preventDefault();
|
||||
addTagHandler();
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
placeholder={$i18n.t('Translation key')}
|
||||
bind:value={newKey}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
addKey();
|
||||
|
||||
@@ -901,6 +901,8 @@
|
||||
const onKeyDown = (e) => {
|
||||
if (
|
||||
e.key === 'Escape' &&
|
||||
!e.isComposing &&
|
||||
e.keyCode !== 229 &&
|
||||
!inboxOpened &&
|
||||
$selectedChatIds.size > 0 &&
|
||||
!showDeleteSelectedConfirm
|
||||
|
||||
@@ -932,6 +932,7 @@
|
||||
e.stopPropagation();
|
||||
}}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') {
|
||||
e.currentTarget.blur();
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@
|
||||
class="flex-1 h-full min-w-0 bg-transparent text-xs text-base-500 dark:text-base-400 outline-hidden"
|
||||
on:blur={saveRename}
|
||||
on:keydown={(e) => {
|
||||
if (e.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === 'Enter') e.currentTarget.blur();
|
||||
if (e.key === 'Escape') {
|
||||
nameDraft = name;
|
||||
|
||||
@@ -627,6 +627,7 @@
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key !== 'Escape') return;
|
||||
if (query) {
|
||||
query = '';
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
on:click|stopPropagation
|
||||
on:keydown={(event) => {
|
||||
event.stopPropagation();
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
rename();
|
||||
|
||||
@@ -401,6 +401,7 @@
|
||||
placeholder={$i18n.t('Folder name')}
|
||||
class="h-4 w-full min-w-0 bg-transparent p-0 text-xs leading-4 outline-none"
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
submitDirectory();
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
positionPopup();
|
||||
}}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
||||
if (optionVoices.length === 0) return;
|
||||
event.preventDefault();
|
||||
|
||||
@@ -550,6 +550,7 @@
|
||||
|
||||
<svelte:window
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (
|
||||
$active &&
|
||||
event.key === 'Escape' &&
|
||||
@@ -748,6 +749,7 @@
|
||||
placeholder={creating === 'file' ? $i18n.t('File name') : $i18n.t('Folder name')}
|
||||
aria-label={creating === 'file' ? $i18n.t('File name') : $i18n.t('Folder name')}
|
||||
on:keydown={(event) => {
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
Reference in new issue
Block a user