Skip to content

[NavigationMenuTrigger] Fix positioner height when opening the list using the keyboard #2060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

juliomerisio
Copy link

@juliomerisio juliomerisio commented Jun 3, 2025

Changes

  • Added missing handleOpenEvent(event) call in the keyboard event handler for arrow key navigation
  • Updated handleOpenEvent to accept both MouseEvent and KeyboardEvent types
  • Added a unit test to validate behavior

Before

before.mp4

After

after.mp4

Copy link

pkg-pr-new bot commented Jun 3, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@base-ui-components/react@2060

commit: 71d7c02

Copy link

netlify bot commented Jun 3, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 71d7c02
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/685417735a69940008376937
😎 Deploy Preview https://deploy-preview-2060--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@atomiks atomiks left a comment

Choose a reason for hiding this comment

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

The fix works correctly 👍

I'll let @michaldudak decide on the infra addition - we usually write our tests with Vitest browser mode with RTL if we need to calculate real sizes for in the browser at the moment (using skipIf(isJSDOM)), which is why the e2e is largely empty

@@ -129,4 +132,48 @@ describe('e2e', () => {
await expect(screen.getByTestId('three')).toHaveFocus();
});
});

describe('<NavigationMenu />', () => {
Copy link
Member

Choose a reason for hiding this comment

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

This test can be added to our unit test suite. We run it in the browser using Vitest's browser mode (using Playwright under the hood).

Copy link
Author

Choose a reason for hiding this comment

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

Nice! I just replaced the Playwright test with the unit test.

);
}

const triggerClassName =
Copy link
Member

Choose a reason for hiding this comment

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

We don't use Tailwind CSS in our tests. Also, we don't need all the bells and whistles in test code, only the minimum to verify the functionality.

Copy link
Author

Choose a reason for hiding this comment

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

Good to know! code removed.

@juliomerisio juliomerisio force-pushed the fix/update-positioner-height branch from 6c07dec to 1ddf978 Compare June 6, 2025 19:41
@juliomerisio juliomerisio requested a review from michaldudak June 6, 2025 19:46
@mui-bot
Copy link

mui-bot commented Jun 19, 2025

Bundle size report

@base-ui-components/reactparsed: 🔺+6B(0.00%) gzip: 🔺+4B(0.00%)

Show details for 39 more bundles

@base-ui-components/react/navigation-menuparsed: 🔺+6B(+0.01%) gzip: 🔺+5B(+0.02%)
@base-ui-components/react/accordionparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/alert-dialogparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/avatarparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/checkboxparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/checkbox-groupparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/collapsibleparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/context-menuparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/dialogparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/direction-providerparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/fieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/fieldsetparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/formparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/inputparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/menuparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/menubarparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/merge-propsparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/meterparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/number-fieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/popoverparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/preview-cardparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/progressparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/radioparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/radio-groupparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/scroll-areaparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/selectparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/separatorparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/sliderparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/switchparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/tabsparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/toastparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/toggleparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/toggle-groupparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/toolbarparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/tooltipparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/unstable-no-ssrparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/unstable-use-media-queryparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/use-renderparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/utilsparsed: 0B(0.00%) gzip: 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 4582b27

Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

There's an issue with the test after merging in the latest master. Could you explicitly import { expect } from 'chai'; in the test file?

juliomerisio and others added 2 commits June 19, 2025 10:57
…er.test.tsx

Co-authored-by: Michał Dudak <[email protected]>
Signed-off-by: Julio Merisio <[email protected]>
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.

4 participants