From 9de310681e441ac72d085eb26b19fe4eab59e828 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 21 Nov 2026 09:21:49 +0000 Subject: [PATCH] focus: a stop that inherits the focus from a removed one is not revealed A removal hands the focus to a neighbour nobody chose to show, so no scroll owner reveals it: a deleted guide or a closed canvas text editor no longer pans the canvas to the stop beside it (photocraft#15555). --- crates/ui-contract/src/runtime/focus.rs | 3 ++- crates/ui-contract/src/runtime/focus/nav.rs | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index 1adf515be..459af9354 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -780,7 +780,8 @@ pub(crate) enum FocusOrigin { /// it counts as an arrival by key, and a text part selects its whole text so typing replaces it. Open, /// The focused stop went away and handed focus to its neighbour: neither the keyboard nor a request chose it, so - /// it is no arrival by key (a deleted guide selects no other guide). + /// it is no arrival by key (a deleted guide selects no other guide) and no scroll owner reveals it (a closed canvas + /// text editor does not pan the canvas to the stop before it). Removal, } diff --git a/crates/ui-contract/src/runtime/focus/nav.rs b/crates/ui-contract/src/runtime/focus/nav.rs index c8a60dd78..32e9b9dcf 100644 --- a/crates/ui-contract/src/runtime/focus/nav.rs +++ b/crates/ui-contract/src/runtime/focus/nav.rs @@ -168,11 +168,14 @@ impl State { self.focus_stop_from(rec, FocusOrigin::Request) } - /// [`focus_stop`](Self::focus_stop) with what moved focus there. + /// [`focus_stop`](Self::focus_stop) with what moved focus there. A stop that inherits the focus from a removed one + /// is not revealed: nothing chose to show it. fn focus_stop_from(&mut self, rec: StopRec, origin: FocusOrigin) -> Vec { let key = rec.stop.key(); let acts = self.enter_stop(rec, origin); - self.revealed = Some(key); + if origin != FocusOrigin::Removal { + self.revealed = Some(key); + } acts }