mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-15 09:31:21 +00:00
fix: holding Shift shows the Delete buttons again after a mouse click (#33717)
On the Notes, Models, Prompts, Skills, Tools and Automations pages, holding Shift is the quick-delete shortcut that turns each item's menu button into a Delete button. It stopped working once any button on the page had been clicked, for example after switching Notes to Grid view, and now works again. A menu button reached with the Tab key still stays a menu button while Shift is held, so keyboard users do not delete by accident. Fixes #33714
This commit is contained in:
parent
35d946f276
commit
680202aa88
6 changed files with 66 additions and 24 deletions
|
|
@ -320,11 +320,16 @@
|
|||
dropzoneElement?.addEventListener('drop', onDrop);
|
||||
dropzoneElement?.addEventListener('dragleave', onDragLeave);
|
||||
|
||||
let keyboardFocusedElement: Element | null = null;
|
||||
const onFocusIn = (event: FocusEvent) => {
|
||||
const target = event.target as Element;
|
||||
keyboardFocusedElement = target.matches(':focus-visible:not(input, textarea)')
|
||||
? target
|
||||
: null;
|
||||
};
|
||||
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.key === 'Shift' &&
|
||||
!document.activeElement?.matches(':focus-visible:not(input, textarea)')
|
||||
) {
|
||||
if (event.key === 'Shift' && document.activeElement !== keyboardFocusedElement) {
|
||||
shiftKey = true;
|
||||
openNoteMenuId = null;
|
||||
}
|
||||
|
|
@ -340,6 +345,7 @@
|
|||
shiftKey = false;
|
||||
};
|
||||
|
||||
window.addEventListener('focusin', onFocusIn);
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
window.addEventListener('keyup', onKeyUp);
|
||||
window.addEventListener('blur', onBlur);
|
||||
|
|
@ -347,6 +353,7 @@
|
|||
return () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
|
||||
window.removeEventListener('focusin', onFocusIn);
|
||||
window.removeEventListener('keydown', onKeyDown);
|
||||
window.removeEventListener('keyup', onKeyUp);
|
||||
window.removeEventListener('blur', onBlur);
|
||||
|
|
|
|||
|
|
@ -488,11 +488,16 @@
|
|||
await tick();
|
||||
loaded = true;
|
||||
|
||||
let keyboardFocusedElement: Element | null = null;
|
||||
const onFocusIn = (event: FocusEvent) => {
|
||||
const target = event.target as Element;
|
||||
keyboardFocusedElement = target.matches(':focus-visible:not(input, textarea)')
|
||||
? target
|
||||
: null;
|
||||
};
|
||||
|
||||
const onKeyDown = (event) => {
|
||||
if (
|
||||
event.key === 'Shift' &&
|
||||
!document.activeElement?.matches(':focus-visible:not(input, textarea)')
|
||||
) {
|
||||
if (event.key === 'Shift' && document.activeElement !== keyboardFocusedElement) {
|
||||
shiftKey = true;
|
||||
}
|
||||
};
|
||||
|
|
@ -507,11 +512,13 @@
|
|||
shiftKey = false;
|
||||
};
|
||||
|
||||
window.addEventListener('focusin', onFocusIn);
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
window.addEventListener('keyup', onKeyUp);
|
||||
window.addEventListener('blur', onBlur);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('focusin', onFocusIn);
|
||||
window.removeEventListener('keydown', onKeyDown);
|
||||
window.removeEventListener('keyup', onKeyUp);
|
||||
window.removeEventListener('blur', onBlur);
|
||||
|
|
|
|||
|
|
@ -351,11 +351,16 @@
|
|||
openCreateModal();
|
||||
}
|
||||
|
||||
let keyboardFocusedElement: Element | null = null;
|
||||
const onFocusIn = (event: FocusEvent) => {
|
||||
const target = event.target as Element;
|
||||
keyboardFocusedElement = target.matches(':focus-visible:not(input, textarea)')
|
||||
? target
|
||||
: null;
|
||||
};
|
||||
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.key === 'Shift' &&
|
||||
!document.activeElement?.matches(':focus-visible:not(input, textarea)')
|
||||
) {
|
||||
if (event.key === 'Shift' && document.activeElement !== keyboardFocusedElement) {
|
||||
shiftKey = true;
|
||||
}
|
||||
};
|
||||
|
|
@ -370,6 +375,7 @@
|
|||
shiftKey = false;
|
||||
};
|
||||
|
||||
window.addEventListener('focusin', onFocusIn);
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
window.addEventListener('keyup', onKeyUp);
|
||||
window.addEventListener('blur', onBlur);
|
||||
|
|
@ -377,6 +383,7 @@
|
|||
return () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
window.removeEventListener('message', onMessage);
|
||||
window.removeEventListener('focusin', onFocusIn);
|
||||
window.removeEventListener('keydown', onKeyDown);
|
||||
window.removeEventListener('keyup', onKeyUp);
|
||||
window.removeEventListener('blur', onBlur);
|
||||
|
|
|
|||
|
|
@ -303,11 +303,16 @@
|
|||
viewOption = localStorage?.workspaceViewOption || '';
|
||||
loaded = true;
|
||||
|
||||
let keyboardFocusedElement: Element | null = null;
|
||||
const onFocusIn = (event: FocusEvent) => {
|
||||
const target = event.target as Element;
|
||||
keyboardFocusedElement = target.matches(':focus-visible:not(input, textarea)')
|
||||
? target
|
||||
: null;
|
||||
};
|
||||
|
||||
const onKeyDown = (event) => {
|
||||
if (
|
||||
event.key === 'Shift' &&
|
||||
!document.activeElement?.matches(':focus-visible:not(input, textarea)')
|
||||
) {
|
||||
if (event.key === 'Shift' && document.activeElement !== keyboardFocusedElement) {
|
||||
shiftKey = true;
|
||||
}
|
||||
};
|
||||
|
|
@ -322,12 +327,14 @@
|
|||
shiftKey = false;
|
||||
};
|
||||
|
||||
window.addEventListener('focusin', onFocusIn);
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
window.addEventListener('keyup', onKeyUp);
|
||||
window.addEventListener('blur', onBlur);
|
||||
|
||||
return () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
window.removeEventListener('focusin', onFocusIn);
|
||||
window.removeEventListener('keydown', onKeyDown);
|
||||
window.removeEventListener('keyup', onKeyUp);
|
||||
window.removeEventListener('blur', onBlur);
|
||||
|
|
|
|||
|
|
@ -299,11 +299,16 @@
|
|||
await init();
|
||||
loaded = true;
|
||||
|
||||
let keyboardFocusedElement: Element | null = null;
|
||||
const onFocusIn = (event: FocusEvent) => {
|
||||
const target = event.target as Element;
|
||||
keyboardFocusedElement = target.matches(':focus-visible:not(input, textarea)')
|
||||
? target
|
||||
: null;
|
||||
};
|
||||
|
||||
const onKeyDown = (event) => {
|
||||
if (
|
||||
event.key === 'Shift' &&
|
||||
!document.activeElement?.matches(':focus-visible:not(input, textarea)')
|
||||
) {
|
||||
if (event.key === 'Shift' && document.activeElement !== keyboardFocusedElement) {
|
||||
shiftKey = true;
|
||||
}
|
||||
};
|
||||
|
|
@ -318,12 +323,14 @@
|
|||
shiftKey = false;
|
||||
};
|
||||
|
||||
window.addEventListener('focusin', onFocusIn);
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
window.addEventListener('keyup', onKeyUp);
|
||||
window.addEventListener('blur', onBlur);
|
||||
|
||||
return () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
window.removeEventListener('focusin', onFocusIn);
|
||||
window.removeEventListener('keydown', onKeyDown);
|
||||
window.removeEventListener('keyup', onKeyUp);
|
||||
window.removeEventListener('blur', onBlur);
|
||||
|
|
|
|||
|
|
@ -324,11 +324,16 @@
|
|||
loaded = true;
|
||||
ensureChannels();
|
||||
|
||||
let keyboardFocusedElement: Element | null = null;
|
||||
const onFocusIn = (event: FocusEvent) => {
|
||||
const target = event.target as Element;
|
||||
keyboardFocusedElement = target.matches(':focus-visible:not(input, textarea)')
|
||||
? target
|
||||
: null;
|
||||
};
|
||||
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.key === 'Shift' &&
|
||||
!document.activeElement?.matches(':focus-visible:not(input, textarea)')
|
||||
) {
|
||||
if (event.key === 'Shift' && document.activeElement !== keyboardFocusedElement) {
|
||||
shiftKey = true;
|
||||
openAutomationMenuId = null;
|
||||
}
|
||||
|
|
@ -344,6 +349,7 @@
|
|||
shiftKey = false;
|
||||
};
|
||||
|
||||
window.addEventListener('focusin', onFocusIn);
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
window.addEventListener('keyup', onKeyUp);
|
||||
window.addEventListener('blur', onBlur);
|
||||
|
|
@ -351,6 +357,7 @@
|
|||
return () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
|
||||
window.removeEventListener('focusin', onFocusIn);
|
||||
window.removeEventListener('keydown', onKeyDown);
|
||||
window.removeEventListener('keyup', onKeyUp);
|
||||
window.removeEventListener('blur', onBlur);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue