beverloo / peter.sh

Source-code for http://peter.sh/.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to close notification after reply?

FluorescentHallucinogen opened this issue · comments

Steps to reproduce:

  1. Open https://tests.peter.sh/notification-generator/
  2. Allow to show notifications in the browser permission prompt
  3. Select "One action (type text)" in the "Actions" dropdown menu
  4. Click "Display the notification" button
  5. Receive the notification and click "Reply" action button
  6. Type something
  7. Click "Send" icon

notification-inline-reply-android-1

Expected behavior:

The notification should close after clicking on "Send" icon

Current behavior:

If "Close it?" checkbox is unchecked, after clicking on "Send" icon it becomes a spinner that spins endlessly. The notification won't close.

notification-inline-reply-android-2

If "Close it?" checkbox is checked, after clicking on "Send" icon the typed text is added at the top, you can click "Reply" action button again, type something, and click "Send" icon, this text is also added at the top. The notification won't close.

notification-inline-reply-android-3

Question

How to close the notification after reply? Should I return a promise in notificationclick event listener in addition to event.notification.close() or something else?

Is it a bug in Chrome for Android? The notification successfully closes in Chrome on Windows after clicking "Reply" action button (in both cases, if "Close it?" checkbox is checked or unchecked):

notification-inline-reply-windows

@beverloo @gauntface @anitawoodruff Please help me figure it out. 😉

Just found that if notificationclick event listener has event.notification.close() inside, then on some Android devices the notification successfully closes after clicking on "Send" icon, but on some not, the typed text is just added at the top.

This is exactly the same as the behavior of native Android apps on these devices. I've tested in Telegram. On some Android devices the notification successfully closes after clicking on "Send" icon, but on some not, the typed text is just added at the top.

But if notificationclick event listener has no event.notification.close() inside, then after clicking on "Send" icon it becomes a spinner that spins endlessly, the notification won't close on all Android devices.

@beverloo I think this is a bug, the spinner shouldn't spin endlessly, the notification should close (after some timeout). Could you please confirm?

Just found a very similar problem on StackOverflow: https://stackoverflow.com/q/51815139.

That certainly sounds like an issue on certain builds of Android—this is one of Chrome's manual test cases iirc. The intended behaviour in the spec (& in Chrome's implementation) is that calling notification.close() always closes the notification.

@beverloo Could you please try to reproduce it yourself on your Android devices and your https://tests.peter.sh/notification-generator/ test page? But just remember, we are talking only about the notification inline reply case.

As I said, there are 2 problems:

  1. If there is event.notification.close(), the"Send" icon becomes a spinner that spins endlessly, and the notification won't close.
  2. If there is no event.notification.close(), the typed text is just added at the top, and the notification won't close.