-
Notifications
You must be signed in to change notification settings - Fork 57
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
fix: safari focus #997
Merged
merlinpaypal
merged 13 commits into
paypal:develop
from
jadutter:hotfix/safari-modal-focus
Oct 17, 2023
Merged
fix: safari focus #997
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
81551bc
- added debug levels to control logging verbosity
jadutter d54b0e3
undid refactors related to improving debugging
jadutter a2e81fe
addressed some code review feedback, and improved focus handling
jadutter f2b7b2d
improved focus handling
jadutter 8baa35d
Merge branch 'develop' into hotfix/safari-modal-focus
jadutter f845289
Merge branch 'develop' into hotfix/safari-modal-focus
jadutter e228aa9
removed unnecessary changes
jadutter b62b5a3
removed unneeded autofocus
jadutter 97368f8
fixed typo
jadutter 8af4b6b
implemented code review changes and removed unnecessary uses of reque…
jadutter abd4979
implemented code review changes
jadutter af94c50
implemented code review changes
jadutter f4d2177
implemented code review changes
jadutter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there an event we should be looking for like the document
DOMContentLoaded
or windowload
event? If so would we be able to leverage these either of these helpers? https://github.com/paypal/paypal-messaging-components/blob/develop/src/utils/events.js#L11-L21. If we aren't waiting for a specific DOM event and just need to ensure the browser has had a render cycle, could we userequestAnimationFrame
instead? The primary concern withsetTimeout
is it is an arbitrary time that may or may not fire the same based on device performance.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.
While manually testing in Safari, I found that
autofocus
attributeiframe
for the modal in the parent page needed to receive focusThe events appeared to be happening in the correct order, but from what I could tell, the iframe was going to be given focus, but had not yet received focus (I found something similar happening with the tabTrap).
I thought about setting up listeners to ensure the button focused happened after the
iframe
, but I realized I would needI thought about it some more, and I figured the direct pipeline I would setup would be unideal. We are already using
MODAL_EVENT.MODAL_SHOW
to communicate almost the same thing. Creating a pipelline forMODAL_EVENT.FOCUS
seemed like a lot of extra code to add onto messaging just to focus the close button.I found that bumping it to a different place in the event cycle was enough for it to behave correctly though, not necessarily needing to wait literally 10ms.
I'll change it to
requestAnimationFrame
since it appears to work too.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.
After further testing, I've realized my PR only partially fixed the issue:
Going to keep working on it
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.
I've gotten it to a decent state, I think. The two caveats I'm thinking of are:
focus()
on the close button. Since the modal can still be navigated after the iframe for the modal receives focus, I was going to let this one go