Skip to content

fix(react-headless-components-preview): constrain menu height and enable internal scrolling - #37005

Open
Paul Mardling (PaulGMardling) wants to merge 4 commits into
microsoft:masterfrom
PaulGMardling:fix/39650-menu-cover-target-styling
Open

Paul Mardling (PaulGMardling) wants to merge 4 commits into
microsoft:masterfrom
PaulGMardling:fix/39650-menu-cover-target-styling

Conversation

@PaulGMardling

@PaulGMardling Paul Mardling (PaulGMardling) commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Previous Behavior

Long menus can leave keyboard-focused items off-screen in short viewports.

New Behavior

Headless Menu constrains its height and scrolls focused items into view, including after resizing. Styled consumers inherit the fix without positioning adapters or sizing CSS. Covering menus stay content-sized; native fallbacks and consumer overrides are preserved.

Before / after

320x240, light/LTR, macOS Chrome 155; End focuses Item 40 in both images. Same consumer fixture and styles; before uses headless 0.3.1, after uses this PR's implementation.

Before: focus is off-screen After: menu scrolls to focused item
Before: Item 40 has keyboard focus outside the viewport After: focused Item 40 is visible through internal menu scrolling

Verified: 1,729 unit tests, both React 17/18 browser suites, native Menu navigation, and 14 styled-consumer scenarios passed. Bundle comparison passes without changing thresholds. Existing skips/pending cases remain; no screen-reader or cross-platform verification is claimed.

Reproduction and validation commands

Use an isolated checkout of this PR and run yarn install --immutable. Open Menu.cy.tsx with yarn nx run react-headless-components-preview:e2e --configuration=local. In a 320x240 long-menu case, focus Actions, open with Enter, and navigate to Item 40: it must be visible through internal scrolling with no page scroll. Escape must close and return focus.

Commands run successfully:

yarn nx run react-headless-components-preview:test --maxWorkers=2 --workerIdleMemoryLimit=512MB
# 1,729 passed; 99 existing skipped
yarn nx run-many -t test-rit--17--e2e test-rit--18--e2e -p react-headless-components-preview --excludeTaskDependencies --skip-nx-cache
# Each React version: 308 passed; 46 existing pending
CYPRESS_nativeFocusgroup=true yarn nx run react-headless-components-preview:e2e --spec 'src/components/Menu/Menu.cy.tsx' --skip-nx-cache --config retries=0
# 25 passed with native focusgroup support asserted
yarn nx run react-headless-components-preview:bundle-size --skip-nx-cache
# TeachingPopover: 37,110 bytes; actual master comparison passed under unchanged 10% threshold
yarn nx run react-headless-components-preview:build
yarn nx run react-headless-components-preview:type-check
yarn nx run react-headless-components-preview:lint
yarn nx run react-headless-components-preview:format:check
# Build, types, lint, and formatting passed

Compatibility suites use Chrome with the focusgroup polyfill; native navigation is checked separately. The built candidate was verified in the styled consumer through external bundler aliases, not an installed fixed release. A release containing this fix is still required for normal dependency adoption.

Related Issue(s)

Expose a headless-owned data-cover-target marker from shared positioning, with lifecycle cleanup and consumer-attribute reconciliation. Cover component composition, nesting, geometry and keyboard behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-headless-components-preview
react-headless-components-preview: entire library
269.204 kB
80.184 kB
272.695 kB
81.53 kB
3.491 kB
1.346 kB
react-headless-components-preview
@fluentui/react-headless-components-preview/tag-picker
50.254 kB
16.375 kB
53.609 kB
17.665 kB
3.355 kB
1.29 kB
react-headless-components-preview
@fluentui/react-headless-components-preview/teaching-popover
33.766 kB
11.09 kB
37.135 kB
12.399 kB
3.369 kB
1.309 kB
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-headless-components-preview
react-headless-components-preview: Calendar
42.084 kB
13.907 kB
🤖 This report was generated against 945d9def1e1187f297a7139791b1f9be396d5e32

@github-actions

Copy link
Copy Markdown

Pull request demo site: URL

Default menus to height autosizing and internal overflow scrolling. Compute available dimensions across permitted native placements, preserve covering geometry and consumer overrides, and keep retained focus visible when the viewport shrinks. Add shared size support, browser regressions and API documentation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@PaulGMardling Paul Mardling (PaulGMardling) changed the title fix(headless): expose cover-target state for surface styling fix(headless): keep focused menu items visible in constrained viewports Oct 26, 2026
@PaulGMardling
Paul Mardling (PaulGMardling) marked this pull request as ready for review October 26, 2026 16:06
@PaulGMardling Paul Mardling (PaulGMardling) changed the title fix(headless): keep focused menu items visible in constrained viewports fix(headless): constrain menu height and enable internal scrolling Oct 26, 2026
@PaulGMardling Paul Mardling (PaulGMardling) changed the title fix(headless): constrain menu height and enable internal scrolling fix: constrain headless Menu height and enable internal scrolling Oct 26, 2026
@PaulGMardling Paul Mardling (PaulGMardling) changed the title fix: constrain headless Menu height and enable internal scrolling fix(react-headless-components-preview): constrain menu height and enable internal scrolling Oct 26, 2026
… align browser tests

Share axis calculations and viewport listener setup without changing autosize behavior or bundle thresholds. Run compatibility suites in Chrome with the existing focusgroup polyfill, while retaining explicit native focusgroup coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…nd resize observation

Normalize CSS zoom coordinates, select compatible two-axis placement limits, and observe absolute containing-block changes. Consolidate positioning observation and add browser and unit regressions for all three review findings.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant