fix: focus existing session tab on mobile Safari
Use window.open with target, then call focus() when available to switch to an existing session tab. Fall back to same-tab navigation if the popup is blocked or focus is unavailable.
This commit is contained in:
@@ -1132,8 +1132,7 @@ class LocalServer:
|
|||||||
card.appendChild(body);
|
card.appendChild(body);
|
||||||
card.appendChild(meta);
|
card.appendChild(meta);
|
||||||
card.onclick = () => {{
|
card.onclick = () => {{
|
||||||
// Use tile slug as window name to reuse the same tab for each tile
|
openTile(tile);
|
||||||
window.open(`/?route_key=${{encodeURIComponent(tile.slug)}}`, `webterm-${{tile.slug}}`);
|
|
||||||
}};
|
}};
|
||||||
card.img = img;
|
card.img = img;
|
||||||
return card;
|
return card;
|
||||||
@@ -1165,7 +1164,14 @@ class LocalServer:
|
|||||||
// Typeahead search functions
|
// Typeahead search functions
|
||||||
function openTile(tile) {{
|
function openTile(tile) {{
|
||||||
if (!tile || !tile.slug) return;
|
if (!tile || !tile.slug) return;
|
||||||
window.open(`/?route_key=${{encodeURIComponent(tile.slug)}}`, `webterm-${{tile.slug}}`);
|
const url = `/?route_key=${{encodeURIComponent(tile.slug)}}`;
|
||||||
|
const target = `webterm-${{tile.slug}}`;
|
||||||
|
const win = window.open(url, target);
|
||||||
|
if (win && typeof win.focus === 'function') {{
|
||||||
|
win.focus();
|
||||||
|
}} else {{
|
||||||
|
window.location.href = url;
|
||||||
|
}}
|
||||||
// Dismiss typeahead after launching from floating results.
|
// Dismiss typeahead after launching from floating results.
|
||||||
searchQuery = '';
|
searchQuery = '';
|
||||||
activeResultIndex = -1;
|
activeResultIndex = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user