zendeskgarden / react-components

:seedling: garden React components
https://zendeskgarden.github.io/react-components/
Apache License 2.0
1.1k stars 89 forks source link

fix(dropdowns): ensure focus is returned to menu trigger before calling `onChange` #1930

Closed ze-flo closed 1 month ago

ze-flo commented 1 month ago

Description

This PR bumps @zendeskgarden/container-menu to v0.5.0 with two key changes:

  1. Menu now returns focus to the trigger before calling onChange, improving A11y for implementations that open modals after selection (see https://github.com/zendeskgarden/react-components/pull/1931)
  2. defaultFocusedValue only applies when opening the menu via keyboard, aligning with APG examples

These changes improve accessibility and user experience, especially for keyboard navigation and complex UI interactions.

💥 BREAKING CHANGE:

Menu: new restoreFocus prop (default: true) returns focus to trigger after menu interaction. When menu expansion is controlled to allow multiple item selection, set restoreFocus={false} and manage trigger focus manually on close.

Detail

Checklist