Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should a non-persistent notification be auto-closed or not? #204

Open
saschanaz opened this issue Feb 9, 2024 · 3 comments
Open

Should a non-persistent notification be auto-closed or not? #204

saschanaz opened this issue Feb 9, 2024 · 3 comments

Comments

@saschanaz
Copy link
Member

What is the issue with the Notifications API Standard?

Currently the spec says: https://notifications.spec.whatwg.org/#lifetime-and-ui-integrations

User agents should run the close steps for a non-persistent notification a couple of seconds after they have been created.

The actual browser behavior is different:

  1. Chrome and Firefox on Windows do not auto-close non-persistent notifications; and instead clicking the notification after tab close just opens the origin URL.
  2. Safari and Firefox on macOS/Linux auto-close non-persistent notifications if the navigation happens away from the triggering page

We had internal argument against the second behavior; non-persistent notification may also include some crucial content that user would like to keep in the notification center. My immediate impression is that such notification should use persistent way instead, but given the browser differences, I think should discuss about the behavior here for better interop.

@saschanaz
Copy link
Member Author

saschanaz commented Feb 13, 2024

Also nobody clears non-persistent notifications from workers 👀 (Except Firefox has no navigator.serviceWorker at all in workers)

Edit: Maybe we should get something corresponding to declarative web push so that script-triggered persistent notifications won't depend on service workers either.

@reillyeon
Copy link

Chrome and Safari (haven't tested Firefox) violate the next line as well:

User agents should not display non-persistent notification in a platform’s "notification center" (if available).

Chrome on Windows and ChromeOS (haven't tested other platforms) add non-persistent notifications to the platform's "notification center". Safari does as well, though as mentioned above it removes them when the tab is navigated or closed. Chrome does not.

@annevk
Copy link
Member

annevk commented Dec 6, 2024

just opens the origin URL

From all the things this is the weirdest behavior listed to me, but we could allow this as one of the alternatives. It could use the same vague-ish definition we plan to use for navigate. I'm not convinced interop matters much here as this is all UI-related and the only issue about it in over a dozen years has been from a browser engineer.

I'd also be happy to remove or weaken most of the other requirements in this section. I'd probably keep the non-persistent/persistent distinction as-is as it's kinda a pain to rename and it still seems accurate lifetime-wise, at least from the perspective of the web developer.

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

No branches or pull requests

3 participants