Skip to content

feat(core,react,html): add generic menu view navigation#1510

Merged
sampotts merged 12 commits intofeat/menu-react-htmlfrom
feat/menu-sub
May 6, 2026
Merged

feat(core,react,html): add generic menu view navigation#1510
sampotts merged 12 commits intofeat/menu-react-htmlfrom
feat/menu-sub

Conversation

@sampotts
Copy link
Copy Markdown
Collaborator

@sampotts sampotts commented May 5, 2026

Summary

Adds PR 3 of the menu system: generic in-place menu view navigation for nested
menus across core, React, HTML, and the sandbox examples.

This keeps the public composition model as nested Menu.Root / nested
<media-menu>, but moves the transition internals away from submenu-specific
slide assumptions. Core now exposes generic menu view lifecycle hooks that CSS
can use for slide, fade, scale, crossfade, or no animation.

What changed

  • Added generic core menu view transition helpers:
    createMenuViewTransition(), getMenuViewTransitionAttrs(), and
    syncMenuViewTransition().
  • Added root/child view state hooks with data-menu-view,
    data-menu-view-state, data-direction, data-starting-style, and
    data-ending-style.
  • Replaced data-submenu-active with generic root view state via
    data-menu-view-state="inactive".
  • Added shared viewport sizing for menu view changes through
    --media-menu-width and --media-menu-height.
  • Added React Menu.View and Menu.Back, with nested Menu.Content portaled
    into the parent viewport.
  • Added HTML <media-menu-view> and <media-menu-back>, with nested
    <media-menu> linked by commandfor.
  • Updated React and HTML sandbox templates so animation styling stays in
    Tailwind/CSS data-attribute classes.
  • Updated the menu design doc and implementation plan to describe Menu.View
    as an in-place shared-viewport view boundary, not a requirement for future
    flyout submenus.

Notes

  • Traditional flyout submenus are intentionally out of scope for this PR.
  • The current default nested menu behavior remains the video-player settings
    style: in-place view navigation inside a shared viewport.
  • Core still owns measurement and sizing variables; authored motion styling
    stays in CSS.

Validation

  • pnpm -F @videojs/core test src/dom/ui/menu/tests/menu-viewport-transition.test.ts src/dom/ui/menu/tests/create-menu-view-transition.test.ts src/dom/ui/menu/tests/create-menu.test.ts
  • pnpm -F @videojs/react test src/ui/menu/tests/menu.test.tsx
  • pnpm -F @videojs/html test src/ui/menu/tests/menu-element.test.ts
  • pnpm -F @videojs/core build
  • pnpm -F @videojs/react build
  • pnpm -F @videojs/html build
  • pnpm typecheck
  • pnpm check:workspace
  • Browser checked React and HTML sandbox submenu transitions with slowed
    animation timing.

Note

Medium Risk
Adds a new submenu/navigation state machine with view transitions, focus restoration, and viewport sizing across core/React/HTML; regressions are possible in keyboard handling and menu open/close behavior. Risk is moderate due to broad surface-area changes but remains UI-scoped (no auth/data).

Overview
Enables generic in-place view navigation for nested menus by introducing a shared menu-viewport model (root view + child views) driven by new data-menu-view* attributes, data-direction, and transition lifecycle hooks.

Core createMenu() now tracks a submenu stack via navigationInput and exposes push/pop, plus a new createMenuViewTransition() and menu-viewport-transition to coordinate enter/exit phases, focus restoration, and --media-menu-width/height sizing during view changes.

React and HTML menu implementations adopt this model: React adds Menu.View and Menu.Back, updates nested Menu.Root/Trigger/Content to operate in submenu mode (including portaling nested content into the parent viewport) and to pop on selection; HTML adds <media-menu-view> and <media-menu-back>, implements commandfor-linked submenus, and updates event/escape handling to respect defaultPrevented. Sandboxes and docs are updated to demonstrate and describe the new navigation pattern.

Reviewed by Cursor Bugbot for commit 9e83021. Bugbot is set up for automated code reviews on this repo. Configure here.

Implements PR 3 of the menu system with nested Menu.Root detection and in-place
menu view navigation. A nested Menu.Root detects its parent MenuContext and
operates as a submenu automatically, while core exposes generic view lifecycle
hooks so CSS can choose slide, fade, scale, crossfade, or no animation.

- Core/dom: Add NavigationState, push/pop to MenuApi and createMenu(), plus
  createMenuViewTransition() and syncMenuViewTransition() for generic view
  enter/exit hooks, root view active/inactive state, focus restoration, and
  viewport width/height measurement.
- React: Add Menu.View and Menu.Back, portal nested Menu.Content into the parent
  viewport, apply generic data-menu-view attrs plus menu semantics separately,
  and auto-pop RadioItem selection in submenu context.
- HTML: Add <media-menu-view> and <media-menu-back>, support nested <media-menu>
  via commandfor, apply the same generic menu view attrs in submenu mode, and
  auto-pop radio selection.
- Sandbox/docs/tests: Update React and HTML menu sandboxes to style motion with
  Tailwind data attrs, document Menu.View as shared-viewport in-place navigation
  only, and cover generic lifecycle attrs across core, React, and HTML tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

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

Project Deployment Actions Updated (UTC)
v10-sandbox Ready Ready Preview, Comment May 5, 2026 4:31am

Request Review

@sampotts sampotts marked this pull request as ready for review May 5, 2026 02:46
@sampotts sampotts mentioned this pull request May 5, 2026
Comment thread packages/react/src/ui/menu/menu-content.tsx
Comment thread packages/html/src/ui/menu/menu-element.ts
Comment thread packages/react/src/ui/menu/menu-trigger.tsx Outdated
Comment thread packages/html/src/ui/menu/menu-element.ts
Comment thread packages/react/src/ui/menu/menu-content.tsx
Comment thread packages/core/src/dom/ui/menu/menu-viewport-transition.ts Outdated
Comment thread packages/html/src/ui/menu/menu-item-element.ts Outdated
Comment thread packages/html/src/ui/menu/menu-element.ts
Comment thread packages/react/src/ui/menu/menu-root.tsx Outdated
Comment thread packages/react/src/ui/menu/menu-content.tsx
Comment thread packages/core/src/dom/ui/menu/menu-viewport-transition.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6d316e4. Configure here.

Comment thread packages/react/src/ui/menu/menu-content.tsx
Comment thread packages/react/src/ui/menu/menu-content.tsx
Copy link
Copy Markdown
Collaborator

@luwes luwes left a comment

Choose a reason for hiding this comment

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

👍

@sampotts sampotts merged commit c002f03 into feat/menu-react-html May 6, 2026
19 checks passed
@sampotts sampotts deleted the feat/menu-sub branch May 6, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants