Bug #105104
closedPreview button in page module does not focus() preview browser tab/window if same resource
100%
Description
In window-manager.js a special condition is added which checks if the browser is trying to open a URL that is already open when a user clicks the "view" button in the page layout module header.
If this is the case, a special logic path is used which reloads that other tab/window's URL - instead of calling window.open().
Unfortunately, this special logic path does NOT call focus() on the target window like the standard code path will do.
The result is that if you're clicking the "view" button but already have a window/tab open with that resource, then that other window/tab is reloaded but is not focused.
(this problem does not exist for the "view" button in the formengine edit form which uses a completely different method for opening the new window/tab).
The behavior should be consistent regardless of which "view" button is clicked and whether or not a window/tab already exists. The good UX solution appears to be that both code paths in window-manager.js should call focus() on the target window.
Code in question:
if (Utility.urlsPointToSameServerSideResource(n, l)) return i.location.replace(n), i.location.reload(), i;
Suggested replacement:
if (Utility.urlsPointToSameServerSideResource(n, l)) return i.location.replace(n), i.location.reload(), i.focus(), i;