notifications icon indicating copy to clipboard operation
notifications copied to clipboard

No way to identify activating action for non-persistent notifications

Open samweinig opened this issue 7 years ago • 5 comments

When activating a non-persistent notification (https://notifications.spec.whatwg.org/#activating-a-notification) that has actions, there is no way to know what action, if any, was clicked to cause the activation. Persistent notifications have the action name since they get NotificationEvents, but non-persistent notifications just get a plain old event.

samweinig avatar May 12 '17 19:05 samweinig

From @beverloo on IRC:

[T]he reason that actions aren't supported on non-persistent notifications is that defining their behaviour when the page goes away is hard

However, it seems we do expose them there API-wise.

annevk avatar May 13 '17 05:05 annevk

https://notifications.spec.whatwg.org/#create-a-notification (step 3) defines that a TypeError should be thrown when using the actions option with the constructor.

Clicking on a non-persistent notification after the page has gone away can right now just open a new tab for the originating page. Imagine such a notification having an "stop bothering me" button—it's impossible to handle that appropriately with the existing API surface.

beverloo avatar May 15 '17 13:05 beverloo

Seems weird to expose them on the Notification object if they can't be used. Perhaps Notification needs to be split into separate classes for persistent and non-persistent variants if their behavior is going to be different?

weinig avatar May 16 '17 00:05 weinig

Any feature that provides alternative interaction with a notification has this problem, e.g. inline replies and select box-like components that the Windows Action Center supports.

I've not heard any developer feedback about this difference in support. /cc @gauntface who might have

I'm not against splitting these off into a separate object (PersistentNotification w/ PersistentNotificationInit?) as it's semantically cleaner, but I'm not convinced such a change would be safe to make. The very vast majority of notifications we show are persistent notifications, and many developers rely on the Notification object for permission checking, feature detection and verifying the number of supported action buttons.

beverloo avatar May 16 '17 13:05 beverloo

Not heard any developer feedback on this although I tend to only hear from developers working with persistent notifications.

gauntface avatar Jun 06 '17 19:06 gauntface