ie-web-notifications / ie-web-notifications.github.io

IE Web Notifications (desktop notifications)
http://ie-web-notifications.github.io/
8 stars 2 forks source link

Giving a tab focus #5

Open GregDThomas opened 9 years ago

GregDThomas commented 9 years ago

When using Chrome/Firefox, it's possible to use the following construct to give the tab that created the notification focus when the notification is clicked;

notification.onclick = function () {
    window.focus();
};

That doesn't work with your plugin; I suspect because it's not natively implemented the browser security model prevents the focus from being changed, event though it's on a user action.

As a work around, could you add an additional configuration option, something like

notification.focusOnClick = true;

that would indicate that the focus should switch to the opening tab; There is an example of how to set the focus to a specific tab at http://stackoverflow.com/questions/3820228/setting-focus-to-already-opened-tab-of-internet-explorer-from-c-sharp-program-us

Thanks

ie-web-notifications commented 9 years ago

Thanks for the bug report, I really think it's a big user experience disadvantage, however I would like to defer it for a while.

Actually, it works (focus method at msdn) but there should be exactly one tab. BTW, in Edge (on Win10) it seems does not work even for one tab.

I have not looked into the way of using accessibility API in details yet but so far I think it can be a little bit confusing from the user experience point of view because it compares URLs of the tabs, so theoretically it's possible to have activated wrong tab if there is another tab with the same url. Also I suspect there can be a race condition which can result in access violation error and finally in a crash of the tab process. I would like to have some more reliable way to achieve it.

BTW, as an experiment it can be done as a separate IE addon which replaces window.focus property by the proper implementation.

Additional resources:

GregDThomas commented 9 years ago

Thanks for the update; regarding comparing URLs of tabs, you're quite right of course, but it may be possible for the plugin to generate a UUID or similar, and use that to guarantee that the right tab is opened. Barring that, you could simply call it a limitation! However, re-implementing window.focus() sounds like a better solution, if that's achievable.

Regarding Edge, the good news is that native Notifications will hopefully be coming "soon" - https://dev.modern.ie/platform/status/webnotifications/?filter=f3f0000bf&search=Web%20Notifications

Roadmap priority: Medium — Development is likely for a future release.