notifications-preview-github icon indicating copy to clipboard operation
notifications-preview-github copied to clipboard

Add option the popup to close on mouseleave

Open darkred opened this issue 4 years ago • 5 comments

Closes #123

Test URLs

https://github.com/

Screenshot

2021-05-05_225054


Note to reviewers

I use .removeAttribute('open') to close the dropdown.

darkred avatar May 05 '21 20:05 darkred

Thank you! I’ll make sure it works correctly soon

fregante avatar May 06 '21 02:05 fregante

I made a change so that the popup close gets canceled if you re-mousenter quick enough, within 1 sec (1000 ms) (and updated the screenshot in the OP).

darkred avatar May 07 '21 14:05 darkred

Hi @fregante Is there any way I can assist you in making the PR complete ?

  Some notes:

  • About the popup closing to be canceled if you re-mousenter quick enough, the interval I currently have is 1000 msec, but I think it should be 500 msec. What do you think?

  • If I click a "Mark as done" and then move the mouse away so that the popup gets closed, then if I move the mouse to reopen the popup, clicking another "Mark as done" unfortunately causes the relevant "Marked x notifications as read" message to be displayed multiple times: e.g. 2021-06-04_201123 So, I tried changing removeAttribute() into remove() the popup altogether + reopening it (see code below) but unfortunately the issue remains:

    using remove() :
    
    		if (options.closeOnMouseleave) {
    			let timer;
    			select('.NPG-dropdown').addEventListener('mouseleave', () => {
    				// timer = setTimeout(closeDropdown, 500);
    				timer = setTimeout(() => {closeDropdown(); createNotificationsDropdown();}, 500);
    			});
    			select('.NPG-dropdown').addEventListener('mouseenter', () => {
    				clearTimeout(timer);
    			});
    		}
    
    // ...
    
    function closeDropdown() {
    	// select('.NPG-container[open]').removeAttribute('open');
    	select('.NPG-container').remove();
    }
    

darkred avatar Jun 04 '21 17:06 darkred

Thank you! I’ll make sure it works correctly soon

@fregante Have you changed your mind? Do you find this PR is not salvageable? Should I close this?

darkred avatar Sep 04 '21 10:09 darkred

I've been on Safari for a year and I haven't used some of my extensions since 😅 so you can just leave this open until someone reviews it

fregante avatar Sep 04 '21 11:09 fregante