Fix close-out-of-view-modals bug that breaks Watch dropdown - #3747
Merged
Conversation
fregante
commented
Nov 20, 2020
Comment on lines
+11
to
+15
| if (intersectionRatio > 0) { | ||
| visible.add(modal); | ||
| } else { | ||
| visible.delete(modal); | ||
| } |
Member
Author
There was a problem hiding this comment.
Too bad that IntersectionObserver doesn't keep a list of entries available at all times, so we have to track what's visible manually.
| const modals = select.all([ | ||
| ':scope > details-menu', // "Watch repo" dropdown | ||
| ':scope > details-dialog', // "Watch repo" dropdown | ||
| ':scope > div > .dropdown-menu' // "Clone or download" and "Repo nav overflow" |
Member
Author
There was a problem hiding this comment.
This PR also reintroduces the feature for other dropdowns. Wish me luck
| // Safety check #3742 | ||
| if (!details.open && lastOpen > Date.now() - 1000) { | ||
| delegation!.destroy(); | ||
| features.error(__filebasename, 'Modal was closed too quickly. Disabling feature'); |
Member
Author
There was a problem hiding this comment.
The drawback is that if the user is Flash, they will see this error in the console. 🤷♂️
fregante
marked this pull request as ready for review
November 20, 2020 20:37
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix #3742
This feature is so fickle because GitHub keeps changing how dropdown works. This time there are 2 elements and both need to be tracked continously.
If it breaks the site again, we drop it.