diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index 8c9a41b..0020131 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -2729,9 +2729,11 @@ // A re-render replaces the text the reader is selecting (a log line to copy, say), so a live change // waits while a button is held or text on the page is selected, and is sent once the selection is // gone. A selection inside a field does not count: fields keep their state across a re-render. + // A selection left behind in a window that lost focus does not hold the page: it updates then. var pressing = false; function selecting() { if (pressing) { return true; } + if (!document.hasFocus()) { return false; } var sel = window.getSelection ? window.getSelection() : null; if (!sel || sel.isCollapsed || !sel.rangeCount) { return false; } var act = document.activeElement; @@ -2744,7 +2746,7 @@ document.addEventListener('pointerup', function () { pressing = false; setTimeout(selectionDone, 0); }, true); document.addEventListener('pointercancel', function () { pressing = false; selectionDone(); }, true); document.addEventListener('selectionchange', selectionDone); - window.addEventListener('blur', function () { pressing = false; }); + window.addEventListener('blur', function () { pressing = false; selectionDone(); }); // A change re-renders the current page. It waits while a navigation is on the wire, since that // response could be superseded: the change is kept and sent after that request completes.