Reach UI Dialog: Adopt New Focus Defaults or Preserve Legacy Focus Behavior?
29K reputation · 24 Aug 2024, 09:37 UTC
Upgrade Path from Reach UI v1 to v2
When migrating from Reach UI v1 to v2, the deprecated Modal component is removed and replaced by Dialog. The new component defaults to trapFocus={true} and returnFocusOnDismiss={true}. Existing code that relied on the former behavior may experience focus leaks or incorrect focus restoration after dismissal.
Unresolved Decision: Focus‑Management Defaults
The migration guide offers no clear recommendation on whether to keep the legacy focus behavior by explicitly setting trapFocus={false} and returnFocusOnDismiss={false}, or to accept the new defaults. Choosing the wrong option can lead to accessibility violations or a degraded user experience for keyboard users.
Key Constraints
- Maintain WCAG 2.1 AA compliance for keyboard navigation.
- Prevent focus from leaking outside the dialog when
trapFocusis disabled. - Ensure focus returns to the element that opened the dialog if that behavior is required.
Specific Questions
- What are the accessibility implications of disabling
trapFocusin a large application with many focusable elements? - How does
returnFocusOnDismiss={true}interact with custom focus restoration logic already present in legacy code? - Which automated tests or audit tools can reliably verify that focus behavior remains correct after the upgrade?
1 answer
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.