fix(contextmenu): fix submenu hover gap — move bridge pseudo-element to parent li#45
fix(contextmenu): fix submenu hover gap — move bridge pseudo-element to parent li#45a652 wants to merge 1 commit into
Conversation
…from submenu to parent li The existing ::before on .wk-ctx-submenu was placed on the wrong element. The 4px gap between parent li and submenu is outside the submenu boundary, so the bridge had no effect. Mouse leaving the parent li over this gap caused the submenu to disappear immediately. Fix: add ::after on the parent li (li:has(> .wk-ctx-submenu)) to extend its hover area rightward by 8px, covering the gap. Mirror fix for flip-submenu (left-opening) case. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Jerry-Xin
left a comment
There was a problem hiding this comment.
This PR is in scope and fixes existing ContextMenus behavior in packages/dmworkbase.
✅ Highlights
- The bridge is now attached to the hovered parent
li, which correctly preservesli:hoverwhile crossing the submenu gap:packages/dmworkbase/src/Components/ContextMenus/index.css:125. - The left-opening submenu case is mirrored correctly for flipped menus:
packages/dmworkbase/src/Components/ContextMenus/index.css:141. - The change is isolated to CSS hit-area behavior; I found no security, data-flow, performance, or architecture regressions.
No blocking issues found.
lml2468
left a comment
There was a problem hiding this comment.
Review — PR #45 fix(contextmenu): submenu hover gap
Verdict: APPROVE ✅
Analysis
Root cause understanding — correct.
The old ::before was on .wk-ctx-submenu itself. A pseudo-element cannot extend outside its parent's box, so it could never bridge the 4px gap between the parent <li> and the submenu. Moving the bridge to the parent <li> via ::after is the right fix because:
.wk-contextmenus lialready hasposition: relative— the::afteranchors correctlyright: -8px; width: 8pxextends the hit area 8px beyond the<li>boundary, fully covering the 4px gap (left: calc(100% + 4px)on the submenu)- Hovering the
::aftermaintainsli:hover, which keepsli:hover > .wk-ctx-submenu { display: block }active
DOM structure verified (read index.tsx at head SHA):
<li> → <ul className="wk-ctx-submenu"> (direct child)
So li:has(> .wk-ctx-submenu) targets correctly.
Flip case — correctly mirrored: left: -8px for .wk-contextmenus-flip-submenu.
Browser compat — :has() is baseline since late 2023 (Chrome 105+, Firefox 121+, Safari 15.4+). No concern for 2026.
No layout side-effects — the ::after is position: absolute so it does not displace any siblings, and the component only supports 1-level nesting (no recursive submenu rendering), so there is no stacking edge case.
Non-blocking note
💬 The pseudo-element has no explicit background: transparent or pointer-events declaration. It works as-is (both default correctly for hit-testing), but a comment /* invisible hover bridge */ one-liner on the content: "" line would help future readers understand the intent at a glance. Completely optional.
Summary
Fix the submenu disappearing issue when moving the mouse from a parent menu item toward its submenu. The submenu was nearly impossible to click due to a 4px gap where hover was lost.
Related Issue
Changes
::beforebridge from.wk-ctx-submenu(was on the wrong element — cannot cover a gap outside its own boundary)::afterbridge on the parentli:has(> .wk-ctx-submenu), extending its hover area 8px rightward to bridge the 4px gap.wk-contextmenus-flip-submenu(left-opening submenu) caseTesting
Reproduced the bug on latest
main: hovering over 「更多」 in the chat list right-click menu and moving the mouse rightward caused the submenu to disappear immediately. After fix, the submenu stays open when crossing the gap.Root cause explanation:
Checklist