Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Make Enter activate the focused confirmation button https://github.com/siyuan-note/siyuan/issues/18460

Danielb51c191e21c9
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts
index e71eeb42fd..ba740e03bb 100644
--- a/app/src/boot/globalEvent/keydown.ts
+++ b/app/src/boot/globalEvent/keydown.ts
@@ -1504,7 +1504,12 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
const confirmDialogElement = document.querySelector('.b3-dialog--open[data-key="dialog-confirm"]');
if (confirmDialogElement) {
if (event.key === "Enter") {
- confirmDialogElement.dispatchEvent(new CustomEvent("click", {detail: event.key}));
+ const activeElement = document.activeElement;
+ if (activeElement instanceof HTMLButtonElement && confirmDialogElement.contains(activeElement)) {
+ activeElement.click();
+ } else {
+ confirmDialogElement.dispatchEvent(new CustomEvent("click", {detail: event.key}));
+ }
event.preventDefault();
return;
} else if (event.key === "Escape") {