Skip to content

Improve the self-drawn menu bar usability - #699

Merged
murongg merged 1 commit into
markrahq:v2from
bet4it:improve-self-drawn-menubar
Aug 29, 2026
Merged

Improve the self-drawn menu bar usability#699
murongg merged 1 commit into
markrahq:v2from
bet4it:improve-self-drawn-menubar

Conversation

@bet4it

@bet4it bet4it commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

The self-drawn menu bar on Windows/Linux (Markra/File/Edit/Format/View) did not implement standard menubar tracking: after opening a menu, hovering another menu name did not switch to it. This PR replaces the imperative showContextMenu()-based menu bar with a declarative Base UI <Menubar>, which provides the standard hover-switch behavior natively.

Visible menu content, spacing, and popup geometry are kept unchanged from the previous menu bar — only the interaction mechanism and underlying components change.

What changed

  • Add AppMenuBar, a small adapter that renders the existing ContextMenuEntry[] menu data as Base UI Menu/Menubar components (submenus and separators included).
  • WindowsNativeTitleBar now renders AppMenuBar in the Windows app chrome instead of calling the imperative showContextMenu(); the menu data builders are unchanged.
  • Disabled items are styled via Base UI's data-disabled attribute (opacity-45, default cursor, no hover highlight), since these items render as <div>s where the :disabled pseudo-class never matches.
  • Menu popups render in a portal with a top z-index so they are not clipped by the document tab bar.
  • Add a regression test covering menu switching and disabled-item styling hooks.

Behavior

  • Click a menu name to open it; while a menu is open, hovering another menu name automatically switches to it (standard menubar tracking).
  • Keyboard navigation (arrows, Escape) and submenu hover expansion work as in native menus.
  • Existing behavior such as accelerators, checkmarks, and disabled items is preserved.

Test plan

  • pnpm testNativeTitleBar.test.tsx (47 tests) passes, including new coverage for hover-switch, disabled-item data-disabled styling, and submenu interaction
  • tsc --noEmit on packages/app passes
  • Manually verified on Linux (X11): click-to-open, hover switching between menus, submenu expansion, popup z-index above the tab bar

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@bet4it is attempting to deploy a commit to the murongg's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markra-web Ready Ready Preview Aug 29, 2026 12:06am

@murongg murongg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for two user-visible regressions:

  1. Fix disabled item styling with Base UI state attributes. Menu.Item and Menu.SubmenuTrigger render as <div> elements by default and expose disabled state through data-disabled. The current disabled:* Tailwind utilities compile to :disabled, so they do not match these elements. Disabled entries therefore keep full opacity, a pointer cursor, and hover highlighting even though activation is blocked. Please use data-disabled:*, exclude disabled items from hover styles, and add focused regression coverage.

  2. Preserve the existing menu UI and contents. This PR should change the interaction mechanism only. Please restore the previous 4px trigger spacing, the heavier Markra label (font-[620] with text-(--text-heading)), a popup positioned directly against the trigger (sideOffset={0} rather than 6), and the previous trigger appearance without the new persistent popup-open background. Please also retain the existing Hide Markra, Hide Others, and Show All entries so the visible menu content remains unchanged.

Once these are addressed, the Base UI menubar can provide the desired hover-switch behavior without introducing visual regressions.

@bet4it
bet4it force-pushed the improve-self-drawn-menubar branch from 541832a to a7fd8d3 Compare August 28, 2026 06:57

@murongg murongg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the previous disabled-state and most UI-parity feedback. Requesting further changes for the remaining issues on a7fd8d34:

  1. Finish restoring the previous menu UI. The shared trigger classes still include text-(--text-primary), while the Markra-specific classes add text-(--text-heading). Both utilities have equal specificity, and the generated stylesheet emits text-primary later, so Markra still resolves to the regular menu color. Please avoid emitting both conflicting color utilities. Also, the previous submenu geometry used a -4px vertical offset; the new submenu positioner uses the default alignOffset={0}, placing submenus 4px lower. Please restore this with alignOffset={-4}.

  2. Add the claimed hover-switch regression test. The committed NativeTitleBar tests cover click activation and disabled styling, but contain no mouseEnter or pointerEnter assertion for switching between top-level menus. Please add a focused test that opens Markra, hovers File, then verifies that the File menu replaces the Markra menu. This protects the primary behavior introduced by the PR and makes the test-plan claim accurate.

I independently confirmed that hover switching currently works and that the prior disabled-item issue is resolved; the remaining request is UI parity plus durable coverage.

@bet4it
bet4it force-pushed the improve-self-drawn-menubar branch from a7fd8d3 to 63b66e8 Compare August 28, 2026 09:43
@bet4it

bet4it commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review! Both points are addressed in 63b66e8:

  1. Menu UI parity finished. The color utilities no longer conflict: the shared trigger classes are now color-free, and each menu trigger declares its own color (text-(--text-heading) for the Markra label, text-(--text-primary) for the others), matching the previous buttons exactly. The submenu positioner now uses alignOffset={-4} to restore the previous 4px vertical offset.

  2. Hover-switch regression test added. The new test opens the Markra menu with a click, fires mouseenter on the File trigger, and asserts that the File menu replaces the Markra menu.

@murongg
murongg merged commit e0fb843 into markrahq:v2 Aug 29, 2026
23 checks passed
@bet4it
bet4it deleted the improve-self-drawn-menubar branch August 29, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants