feat(core): menu core layer and DOM keyboard navigation#1503
Open
feat(core): menu core layer and DOM keyboard navigation#1503
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Adds the core and DOM layers for the menu component (PRs 1+2): Core layer: - `MenuCore` class with ARIA attr helpers, state computation, and defaultProps - `MenuDataAttrs`, `MenuItemDataAttrs`, `MenuCSSVars` constants - Extracts `TransitionDataAttrs` into `transition.ts` and spreads it into Popover, Tooltip, and AlertDialog data-attrs to remove duplication DOM layer: - `createMenu()` factory composing `createPopover` for open/close/escape/outside-click - Roving tabindex with item registration (`registerItem(element) → cleanup`) - Keyboard navigation: ArrowUp/Down (wrap), Home, End, Enter/Space - Type-ahead search with 500ms debounce buffer - Focus management: first item on open, trigger on close animation complete Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48cbddd to
4c8f933
Compare
Two bugs from PR review: 1. destroy() delegated directly to popover.destroy(), leaving a pending requestAnimationFrame (scheduled on open) and typeaheadTimer uncancelled. If destroy() was called shortly after open(), the RAF would fire and call highlight() / element.focus() / onHighlightChange on a destroyed menu. 2. The RAF guard only checked `!active`, but active stays true during the closing animation (status: 'ending'). Calling open(); close() before the RAF fired caused the RAF to still execute and highlight the first item, leaving a stale highlightedItem that prevented focus on the next open. Fixes: add openRafId tracking + cancel on destroy; extend RAF guard to also check status !== 'ending'; wrap destroy() to clear timer and RAF first. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 67decd7. Configure here.
The popover positioning layer already computes and sets availableWidth alongside availableHeight for every popover — omitting it from MenuCSSVars was an inconsistency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The registerItem cleanup was nulling highlightedItem and firing onHighlightChange but leaving data-highlighted and tabIndex=0 on the element. Use clearHighlight() so DOM cleanup, state reset, and callback all happen consistently in one place. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
📦 Bundle Size Report🎨 @videojs/html — no changesPresets (7)
Media (8)
Players (5)
Skins (29)
UI Components (25)
Sizes are marginal over the root entry point. ⚛️ @videojs/react — no changesPresets (7)
Media (7)
Skins (26)
UI Components (21)
Sizes are marginal over the root entry point. 🧩 @videojs/core
Entries (9)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (10)
📦 @videojs/spf — no changesEntries (3)
ℹ️ How to interpretAll sizes are standalone totals (minified + brotli).
Run |
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
First in a stack of PRs implementing the menu component (see #1078 for the design doc).
MenuCore— ARIA attrs, state computation, defaultProps — following the same pattern asPopoverCoreMenuDataAttrs,MenuItemDataAttrs, andMenuCSSVarsconstantsTransitionDataAttrsintotransition.tsand spreads it into Popover, Tooltip, and AlertDialog — removes duplicateddata-starting-style/data-ending-styleentries across four filescreateMenu()DOM factory: composescreatePopoverfor open/close/escape/outside-click, adds roving tabindex item registry, ArrowUp/Down/Home/End/Enter/Space keyboard navigation, 500ms type-ahead, and focus management (first item on open; trigger on close)Stack
feat/menu-core-domfeat/menu-react-htmlfeat/menu-subTest plan
pnpm -F @videojs/core test src/core/ui/menu— 17 tests (MenuCore)pnpm -F @videojs/core test src/dom/ui/menu— 36 tests (createMenu)pnpm typecheck— cleanpnpm lint— clean🤖 Generated with Claude Code
Note
Medium Risk
Adds a new menu primitive with focus/keyboard behavior and composes it with the Popover/DismissLayer lifecycle; regressions could impact accessibility and interaction flows. Also refactors shared transition data-attrs used by popover/tooltip/alert-dialog, which could affect styling/hooks that depend on these attributes.
Overview
Adds the first cut of a
Menuprimitive in@videojs/core: a newMenuCore(state + ARIA attrs),MenuDataAttrs/MenuItemDataAttrs, andMenuCSSVars, and exports these frompackages/core/src/core/index.ts.Introduces
createMenu()in the DOM layer (exported frompackages/core/src/dom/index.ts) that composescreatePopover()for open/close behavior and implements roving-tabindex item registration, Arrow/Home/End navigation, Enter/Space activation, typeahead search, and focus restoration/cleanup.Deduplicates transition-related data attributes by extracting
TransitionDataAttrsintotransition.tsand spreading it intoPopoverDataAttrs,TooltipDataAttrs, andAlertDialogDataAttrs.Reviewed by Cursor Bugbot for commit cd116ca. Bugbot is set up for automated code reviews on this repo. Configure here.