Skip to content

Conversation

@humitos
Copy link
Member

@humitos humitos commented Sep 18, 2024

It detects if the tab is opened and trigger a timeout for 5 seconds. After that time, the notification is hidden.

Eventually, we could use some nice effect, like fade out and stop the timer while the pointer is over the notification -- but that't outside the scope of this initial work.

Peek 2024-09-18 20-17

Closes #366

It detects if the tab is opened and trigger a timeout for 5 seconds. After that
time, the notification is hidden.

Eventually, we could use some nice effect, like fade out and stop the timer
while the pointer is over the notification -- but that't outside the scope of
this initial work.

Closes #366
@humitos humitos requested a review from a team as a code owner September 18, 2024 18:17
@humitos humitos requested a review from agjohnson September 18, 2024 18:17
Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

This looks good! I think we should aim to support hover/focus with this change, which shouldn't be much more more work. We'd need to add the events to the templates and call this same logic from those events.

@humitos
Copy link
Member Author

humitos commented Sep 18, 2024

I'll try something tomorrow. I'd like to not reset the time, but pause it. I may need to save the countdown time for that... Not sure how yet

@agjohnson
Copy link
Contributor

Either works, but resetting seems fine and doesn't require more state tracking. To make a notification that can be paused you could turn the timer into a 1s timer and accumulate a count of seconds unpaused instead.

@humitos humitos merged commit 3525435 into main Sep 19, 2024
@humitos humitos deleted the humitos/auto-dismiss-notification branch September 19, 2024 07:16
Comment on lines +82 to +91
_handleMouseEnter = (e) => {
// Stop the timer when notification is hovered (mouseenter event)
clearTimeout(this.timerID);
this.timerID = null;
};

_handleMouseLeave = (e) => {
// Start the timer when the notification is hovered away (mouseleave)
this.triggerAutoDismissTimer();
};
Copy link
Contributor

Choose a reason for hiding this comment

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

@humitos Note, this doesn't handles the focusin/focusout events I mentioned. These are required for keyboard and screen reader support, which won't fire mouse events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notification: auto-dismiss

3 participants