From 9f9d6be9115d45d4e2e78d9be597cb3865dad0c8 Mon Sep 17 00:00:00 2001 From: cruldra Date: Tue, 25 Aug 2026 22:18:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(vscode):=20=E4=BF=AE?= =?UTF-8?q?=E5=A5=BD=E5=B1=9E=E6=80=A7=E7=BD=91=E6=A0=BC=20SelectMenu=20?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E7=82=B9=E5=87=BB=E8=A2=AB=E6=8D=95=E8=8E=B7?= =?UTF-8?q?=E9=98=B6=E6=AE=B5=E5=A4=84=E7=90=86=E5=99=A8=E5=90=9E=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vscode/webview-ui/src/components/property-grid.tsx | 10 +++++++++- vscode/webview-ui/src/components/ui/select-menu.tsx | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/vscode/webview-ui/src/components/property-grid.tsx b/vscode/webview-ui/src/components/property-grid.tsx index 3245996..fcd165d 100644 --- a/vscode/webview-ui/src/components/property-grid.tsx +++ b/vscode/webview-ui/src/components/property-grid.tsx @@ -531,6 +531,11 @@ function PropertyRow({ ref={el => registerCellRef(fullKey, el)} data-property-cell={fullKey} onClickCapture={(e) => { + // portal 弹层对祖先捕获处理器隐身:点击落在 SelectMenu 弹层内时不选中也不拦截, + // 让 click 正常落到选项按钮,避免被外层的 stopPropagation/preventDefault 吞掉。 + const src = e.target + if (src instanceof Element && src.closest('[data-select-menu]')) + return if (isSelected) return onSelect(fullKey) @@ -606,8 +611,11 @@ export function PropertyGrid({ if (selectedKey == null) return function handleMouseDown(e: MouseEvent): void { + const t = e.target + if (!(t instanceof Node)) + return const root = rootRef.current - if (root && e.target instanceof Node && !root.contains(e.target)) + if (root && !root.contains(t) && !(t instanceof Element && t.closest('[data-select-menu]'))) setSelectedKey(null) } document.addEventListener('mousedown', handleMouseDown) diff --git a/vscode/webview-ui/src/components/ui/select-menu.tsx b/vscode/webview-ui/src/components/ui/select-menu.tsx index ccb022c..128e6f8 100644 --- a/vscode/webview-ui/src/components/ui/select-menu.tsx +++ b/vscode/webview-ui/src/components/ui/select-menu.tsx @@ -211,6 +211,7 @@ export function SelectMenu({