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

[Bug] Push notifications "click to see" not doing anything when click #400

Open
MrPropre opened this issue Mar 2, 2025 · 2 comments
Open
Labels
bug Something isn't working

Comments

@MrPropre
Copy link

MrPropre commented Mar 2, 2025

Describe the bug
When I receive a push notification saying I received a file and "click to see", clicking on the notification does nothing, the notification just disappear.

To Reproduce
Steps to reproduce the behavior:

  1. Open Pairdrop, make sure that push notifications are enabled
  2. Click on another window or tab on your computer
  3. With another device, share a file to your computer
  4. On your computer, click on the notification
  5. It does nothing

Expected behavior
It should focus on the tab/window

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Microsoft Edge (same with Google Chrome)
  • Version: 133.0.3065.92

Bug occurs on official PairDrop instance https://pairdrop.net/
Yes
Version: v1.11.2

Additional context
Binding a callback after this line could be the solution.

const notification = this._notify(title, Localization.getTranslation("notifications.click-to-show"));

@MrPropre MrPropre added the bug Something isn't working label Mar 2, 2025
@schlagmichdoch
Copy link
Owner

It is not possible to create a callback to actively focus the current viewport.

Instead, this is actually the default behavior for click events on Notifications, which is why t:

The click event of the Notification interface fires when the user clicks on displayed Notification.

The default behavior is to move the focus to the viewport of the notification's related browsing context. If you don't want that behavior, call preventDefault() on the event object.

(https://developer.mozilla.org/en-US/docs/Web/API/Notification/click_event)

I’ll need to test this though.

@MrPropre
Copy link
Author

MrPropre commented Mar 2, 2025

It is not possible to create a callback to actively focus the current viewport.

Using a service worker, you can use WindowClient.focus(). There is a detailed example here

Instead, this is actually the default behavior for click events on Notifications

I can confirm this behavior doesn't work on Edge and Chrome on my Windows computer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants