Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix close-out-of-view-modals bug that breaks Watch dropdown - #3747

Merged
fregante merged 3 commits into
masterfrom
close-out-of-view-modals-fix-3742
Nov 24, 2020
Merged

Fix close-out-of-view-modals bug that breaks Watch dropdown#3747
fregante merged 3 commits into
masterfrom
close-out-of-view-modals-fix-3742

Conversation

@fregante

@fregante fregante commented Nov 20, 2020

Copy link
Copy Markdown
Member

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.

@fregante fregante added the bug label Nov 20, 2020
Comment on lines +11 to +15
if (intersectionRatio > 0) {
visible.add(modal);
} else {
visible.delete(modal);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The drawback is that if the user is Flash, they will see this error in the console. 🤷‍♂️

@fregante
fregante marked this pull request as ready for review November 20, 2020 20:37
@fregante
fregante merged commit 09c8033 into master Nov 24, 2020
@fregante
fregante deleted the close-out-of-view-modals-fix-3742 branch November 24, 2020 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

close-out-of-view-modals Breaks the new watch settings

1 participant