-
Notifications
You must be signed in to change notification settings - Fork 309
Issue / 10548 Restore Focus to Trigger When Closing Various Modal Dialogs #10863
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
base: develop
Are you sure you want to change the base?
Issue / 10548 Restore Focus to Trigger When Closing Various Modal Dialogs #10863
Conversation
…rySelector selector.
…ocusQuerySelector selector.
…refocusQuerySelector prop is used on the modal.
…-closing-various-modal-dialogs.
Size Change: +9.71 kB (+0.46%) Total Size: 2.14 MB
ℹ️ View Unchanged
|
Build files for 91d2d12 are ready:
|
…-closing-various-modal-dialogs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @10upsimon , just a few comments from me
assets/js/components/PermissionsModal/AuthenticatedPermissionsModal.js
Outdated
Show resolved
Hide resolved
assets/js/components/consent-mode/ConfirmDisableConsentModeDialog.js
Outdated
Show resolved
Hide resolved
assets/js/components/conversion-tracking/ConfirmDisableConversionTrackingDialog.js
Outdated
Show resolved
Hide resolved
assets/js/components/conversion-tracking/ConversionTrackingToggle.js
Outdated
Show resolved
Hide resolved
Thanks @zutigrm . Most of these sound good but I'd like @techanvil to read over the proposed changes as well, to be sure he is in agreement. I also believe the active check is in place so that pressing escape while the modal is not visible doesn't invoke a refocus, perhaps @techanvil can confirm that. |
Thanks @10upsimon. As discussed on Slack, I've noticed a couple of issues beyond what's been discussed here so far.
|
Thanks @techanvil I update the PR to cover the refocus on the cancel button click, and implemented your proposed approach in the referenced PR. |
Sounds good, thanks @zutigrm! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @10upsimon. I know this is how it was specced out in IB but let's refactor this stuff a bit to make it more reliable and less messy.
Let's create a new RefocusableModalDialog
component that implement what you have added to the ModalDialog
in this PR to separate this logic from the actual dialog implementation. It will have the same props as ModalDialog
has + two new props that you added to this PR.
Inside the RefocusableModalDialog
component you will need to add a useEffect
hook with dialogActive
as the only dependency to track a currently focused element when that prop becomes truthy and restore the focus when it is falsy.
Oh, I see @zutigrm took it over. Aleksej, please, see my comment above. |
Thanks @eugene-manuilov I refactored the current implementation, and removed the unecesarry hook. I tried also to simplify the the last button click, by using Other than that rest of the logic has been simplified, and refocus has been implemented on modal closing and unmount - since we conditionally render the modal in some components, so |
Summary
Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist