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:
Classic298 2026-11-03 23:05:59 +01:00 • committed by GitHub
parent 35d946f276
commit 680202aa88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 66 additions and 24 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);