-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Popover: Check anchorDocument default view before removing events #35832
Conversation
Size Change: +26 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
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.
From what I could tell, focusing the content in a Mobile/Tablet preview changes the anchor.ownerDocument
to the one in the iframe, rather than the main window.
- Show a Tablet preview.
- Click on the post content. (
anchorDocument.defaultView
is the iframe) - Click Preview button. (
anchorDocument.defaultView
is main window) - Click the Desktop option, and the Preview popover closes.
- The active element (and thus the
anchorDocument
) immediately changes back to the one in the iframe. - The effect cleanup function runs right when the iframe is already gone but the
anchorDocument
is still in memory.
Something like that?
If this is what’s happening, then I guess the optional chaining fix won’t cause any issues? I don’t know if there are better fixes, but given that this is an active crash bug, I think it’s good to merge a fix ASAP.
Thanks for the review, @mirka. Yes, that's similar to my findings. However, I'm also not sure how to fix the cause of the issue. So let's merge this band-aid fix for now. |
Is there a way to use |
I can't really think of a solution using focus/blur events, but maybe one thing we could do to prevent memory leaks here is to also remove the resize/scroll listeners in a |
Sounds like an improvement we should apply regardless of what we're trying to solve here, so I'd say yes! |
Description
PR adds optional chaining before removing events on side effect cleanup.
I could not track down why
anchorDocument.defaultView
is null with these specific steps. So this is more like treating the symptom than a cause.Fixes #35807.
How has this been tested?
Types of changes
Bugfix
Checklist:
*.native.js
files for terms that need renaming or removal).