diff --git a/source/github-notifications-preview.jsx b/source/github-notifications-preview.jsx index 604d64a..ce4bfad 100644 --- a/source/github-notifications-preview.jsx +++ b/source/github-notifications-preview.jsx @@ -98,6 +98,16 @@ function createNotificationsDropdown() { ); indicator.addEventListener('mouseenter', openDropdown); + if (options.closeOnMouseleave) { + let timer; + select('.NPG-dropdown').addEventListener('mouseleave', () => { + timer = setTimeout(closeDropdown, 1000); + }); + select('.NPG-dropdown').addEventListener('mouseenter', () => { + clearTimeout(timer); + }); + } + indicator.addEventListener('click', visitNotificationsPage); } } @@ -169,6 +179,10 @@ async function openDropdown({currentTarget: indicator}) { } } +function closeDropdown() { + select('.NPG-container[open]').removeAttribute('open'); +} + // When the dropdown is open, GitHub's modal blocks all links outside the dropdown. // This handler lets the user visit /notifications while retaining any cmd/ctrl click modifier function visitNotificationsPage(event) { diff --git a/source/options-storage.js b/source/options-storage.js index 60ae215..8b43cf9 100644 --- a/source/options-storage.js +++ b/source/options-storage.js @@ -4,6 +4,7 @@ window.optionsStorage = new OptionsSync({ defaults: { previewCount: true, dropdown: 'compact', - participating: false + participating: false, + closeOnMouseleave: false } }); diff --git a/source/options.html b/source/options.html index 608c3a0..af8e16b 100644 --- a/source/options.html +++ b/source/options.html @@ -15,6 +15,12 @@ Show only participating notifications
++ +
Show notifications list on hover: