Skip to content

feat(Menu): cursor-anchored context menu (useContextMenu) + Badge/build tidy - #25

Merged
dahannes merged 3 commits into
mainfrom
feat/context-menu-cursor-anchor
Jul 6, 2026
Merged

feat(Menu): cursor-anchored context menu (useContextMenu) + Badge/build tidy#25
dahannes merged 3 commits into
mainfrom
feat/context-menu-cursor-anchor

Conversation

@dahannes

@dahannes dahannes commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • useContextMenu — a right-click, cursor-anchored menu built on a controlled, non-modal MenuTrigger. Non-modal so a right-click on another element reaches its own handler (a modal underlay swallows it and leaks the native menu); the hook owns dismissal (outside press, right-click elsewhere, Escape) since non-modal drops React-Aria's built-in dismiss. Cursor anchoring via a hidden Pressable anchor moved to the pointer. Context usage demonstrated in the Menu story (no separate component/story). Shared popover chrome extracted to menuStyles.
  • IconButton / IconButtonLink / IconButtonToggle now forward ref (React 19 ref-as-prop).
  • Badgetabular-nums + tracking-wider as defaults (count pills align + read consistently); story rewritten to the Button pattern.
  • buildtsup onSuccess rebuilds dist/index.css in the same pass as JS, so the stylesheet can't go missing mid-rebuild for linked (dev) consumers.

Why

Replaces a querySelector().click() hack in cytario-web's right-click menus (NodeLink, annotation thumbnails) with a real design-system primitive. cytario-web depends on this release: the context menus + the Badge defaults (PanelRow now relies on them).

Notes

  • Not in this PR: a Switch redesign (parked for separate review).
  • Follow-up: cytario-web PR consumes the published version.

dahannes added 3 commits July 6, 2026 09:39
Add useContextMenu — a right-click, cursor-anchored menu built on a
controlled non-modal MenuTrigger. Non-modal so a right-click on another
element reaches its own handler (a modal underlay swallows it and leaks
the native menu); the hook owns dismissal (outside press, right-click
elsewhere, Escape) since non-modal drops React-Aria's built-in dismiss.

Also forward ref on IconButton/IconButtonLink/IconButtonToggle (React 19
ref-as-prop) and extract shared popover chrome to menuStyles. Context
usage is demonstrated in the Menu story (no separate component/story).
Bake tabular-nums and tracking-wider into Badge so count pills align and
read consistently without per-use classes. Rewrite the story to the Button
pattern (AllVariants grid first, Playground, focused examples), dropping the
per-variant/per-size/app-specific slop.
tsup's onSuccess regenerates the stylesheet in the same pass as the JS, so
dist/index.css can't go missing mid-rebuild for linked consumers (dev). Drops
the need for a separate, race-prone CSS watcher.
@dahannes
dahannes merged commit 21abf7d into main Jul 6, 2026
5 checks passed
@dahannes
dahannes deleted the feat/context-menu-cursor-anchor branch July 6, 2026 11:08
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 7.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant