From 0ee9f9753182ad0a867e96f3514f966560caf996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 05:32:19 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20a=20text=20selection=20le?= =?UTF-8?q?ft=20in=20a=20window=20that=20lost=20focus=20no=20longer=20hold?= =?UTF-8?q?s=20live=20updates;=20losing=20focus=20sends=20a=20held=20updat?= =?UTF-8?q?e=20at=20once?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/assets/nav.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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.