fix(slash): handle menu clicks inside shadow DOM#161
Open
Johnson-zq wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 摘要
Fix slash menu item interactions when
createSlashMenuUIis mounted inside aShadowRoot.Motivation / 背景与动机
The document-level outside-click handler used
event.targettogether withroot.contains(target).When a composed event crosses a Shadow DOM boundary,
event.targetis retargeted to the shadow host for listeners outside the shadow tree. As a result, clicking a slash menu item could be incorrectly treated as an outside click, dismissing the menu before the command was confirmed.This change uses the event's composed propagation path so menu-internal interactions are detected correctly in both light DOM and Shadow DOM.
docs/ROADMAP.md): N/AChanges / 变更内容
packages/plugin-slash:event.targetcontainment check withevent.composedPath().ShadowRoot.mousedowndoes not dismiss the menu before the itemclickhandler confirms the command.packages/core: No changes.apps/electron-demo: No code changes.openspec/: Not required for this bug fix.Testing / 测试
pnpm exec vitest run packages/plugin-slash/test/menu-ui.test.ts --reporter=verbosepnpm typecheckpnpm testpnpm --filter @floatboat/nexus-plugin-slash buildpnpm buildShadowRoot./Compliance / 合规自检
AI-assisted notes: AI assistance was used to help inspect the Shadow DOM event propagation path and draft the initial regression-test approach. I reviewed the final changes line by line, verified the event-retargeting behavior, understood the use of
Event.composedPath(), and ran the tests locally.dist/,dist-electron/, or compiled.jsfiles)..envfiles, credentials, or personal vault data committed.Checklist / 自检清单
live-preview-table.ts— N/A, this file was not modified.GOVERNANCE.md§4.Screenshots / Recordings · 截图或录屏
N/A — this change fixes event handling without changing the visual appearance. The Shadow DOM behavior is covered by the new regression test, and the standard light-DOM interaction was manually checked in the Electron demo.