From 99937bd8f49e5e4eff4785c6d113a4edcf875ab0 Mon Sep 17 00:00:00 2001 From: Jin <22962980+JYC333@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:37:36 +0000 Subject: [PATCH] refactor: fix attribute detail can't save with ctrl+enter directly --- .../src/services/attribute_autocomplete.ts | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/client/src/services/attribute_autocomplete.ts b/apps/client/src/services/attribute_autocomplete.ts index 7758862ba7..f3e7d3a36a 100644 --- a/apps/client/src/services/attribute_autocomplete.ts +++ b/apps/client/src/services/attribute_autocomplete.ts @@ -201,13 +201,18 @@ function initAttributeNameAutocomplete({ $el, attributeType, open, onValueChange }, onKeyDown(e, handlers) { if (e.key === "Enter") { + if (e.ctrlKey || e.metaKey) { + // Let the outer widget handle save shortcuts such as Ctrl+Enter. + return; + } + if (isPanelOpen && hasActiveItem) { // Prevent the enter key from propagating to parent dialogs // (which might interpret it as "submit" or "save and close") e.stopPropagation(); - } else if (!isPanelOpen) { - // Panel is closed. Do not pass Enter to autocomplete-core - // so native HTML form submit handlers can run. + } else { + // No active suggestion means the user is keeping their typed value. + // Let outer shortcuts continue to bubble. return; } } @@ -393,10 +398,17 @@ function initLabelValueAutocomplete({ $el, open, nameCallback, onValueChange }: }, onKeyDown(e, handlers) { if (e.key === "Enter") { + if (e.ctrlKey || e.metaKey) { + // Let the outer widget handle save shortcuts such as Ctrl+Enter. + return; + } + if (isPanelOpen && hasActiveItem) { e.stopPropagation(); - } else if (!isPanelOpen) { - return; // Let native submit form bubbling happen + } else { + // No active suggestion means the user is keeping their typed value. + // Let outer shortcuts such as Ctrl+Enter continue to bubble. + return; } } handlers.onKeyDown(e as any);