-
Notifications
You must be signed in to change notification settings - Fork 129
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
Remove custom initial focus logic #2910
Remove custom initial focus logic #2910
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feat/DSYS-878/remove-react-modal #2910 +/- ##
=================================================================
Coverage 88.10% 88.11%
=================================================================
Files 222 221 -1
Lines 12922 12868 -54
Branches 1788 1781 -7
=================================================================
- Hits 11385 11338 -47
+ Misses 1484 1477 -7
Partials 53 53
|
Size Change: -393 B (-0.06%) Total Size: 676 kB
ℹ️ View Unchanged
|
4d0c3ee
into
feat/DSYS-878/remove-react-modal
* split preventClose into 3 different props * refactor side panel with dialog * add backButtonLabel default translations * delete old ModalContext * remove react-modal dependency * refactor: split effects * refactor: dialog props * code review * restore group prop * remove visibility from animations * fix use of refs * fixup! remove visibility from animations * early returns * fix focus issue * Fix Dialog's server-side rendering compat * Simplify Modal JSX * Remove custom initial focus logic (#2910) * fix animation * fix test name * remove isMobile prop * fix props preview in docs * handle escape key events triggered from outside the dialog. * only restore focus to trigger element if focus is within the dialog * update docs * dialog fix * fix sync issues * remove inline use from docs * changes after rebase * increase specificity of the close button --------- Co-authored-by: Connor Bär <[email protected]> Co-authored-by: Connor Bär <[email protected]>
Purpose
Browsers (and the dialog-polyfill) already handle focusing the first interactive element inside a
dialog
element when opened.Approach and changes
initialFocusRef
prop with the nativeautofocus
attribute. React (purposefully 🙄) breaks theautoFocus
property (see autofocus attr not included in button element when rendered facebook/react#11851 (comment)), so we have to work around that by using the lowercase attribute name with a string value to force React to serialize it to the DOM (see Bug: autoFocus broken inside <dialog /> facebook/react#23301). This produces a console warning that can be safely ignored.Definition of done