From 2970ef8cc0f62c971109322e152c103e583c87ca Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 17 Nov 2026 03:07:07 +0000 Subject: [PATCH] Access nodes: a collection's redirect of a row's node is journaled, so a settled dock panel's replay keeps the row's node with the collection and an access Focus on a Layers row focuses the rows --- crates/layers/tests/it/panel_input.rs | 23 +++++++++++++++----- crates/ui-contract/src/runtime/keys/nodes.rs | 3 +++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/crates/layers/tests/it/panel_input.rs b/crates/layers/tests/it/panel_input.rs index 3ead021cb..bf11f6a8f 100644 --- a/crates/layers/tests/it/panel_input.rs +++ b/crates/layers/tests/it/panel_input.rs @@ -5,6 +5,7 @@ use craft_behavior::{EditEvent, EditHistory, Mixed, SelectionChange}; use craft_layers::ui::mock::FakeLayers; use craft_layers::ui::panel::{LayerColumn, LayerDrop, LayerPosition, LayerToggle, LayersEvent, LayersPanel}; use craft_layers::ui::tree::{LayerKind, LayerPart, LayerSelection}; +use craft_ui::contract::Lazy; use craft_ui::testing::access::focused_key; use craft_ui::testing::focus::AccessActionKind; use craft_ui::testing::{Fixture, Target, pointer, trial}; @@ -247,11 +248,23 @@ fn shift_right_and_left_open_and_close_the_active_layers_effects() { /// A row's access focus action, as a screen reader or a test driver gives it, puts key focus in the rows with the /// lead on that row: the access focus lands on the row's node. +/// So does it while the panel is a settled region that replays its last run. #[trial] fn a_rows_access_focus_action_leads_the_focused_rows_to_it() { - let (mut fixture, _app) = rig(FakeLayers::sample()); - let styled = row(&fixture, "Styled"); - fixture.access(AccessActionKind::Focus, &styled).idle(2); - assert!(fixture.focused_stop().is_some(), "the rows hold key focus"); - assert_eq!(focused_key(fixture.tree()), styled.node, "the access focus is on the row"); + let settled = || { + let app = Rc::new(RefCell::new(App { tree: FakeLayers::sample(), events: Vec::new() })); + let shared = Rc::clone(&app); + let mut fixture = Fixture::new(move |ui| { + Lazy::new("layers", 0.0).settles(true).show(ui, |ui| show(ui, &mut shared.borrow_mut())); + }); + fixture.room(PANEL); + fixture.settle(); + (fixture, app) + }; + for (mut fixture, _app) in [rig(FakeLayers::sample()), settled()] { + let styled = row(&fixture, "Styled"); + fixture.access(AccessActionKind::Focus, &styled).idle(2); + assert!(fixture.focused_stop().is_some(), "the rows hold key focus"); + assert_eq!(focused_key(fixture.tree()), styled.node, "the access focus is on the row"); + } } diff --git a/crates/ui-contract/src/runtime/keys/nodes.rs b/crates/ui-contract/src/runtime/keys/nodes.rs index 9426a018b..f6e13fbac 100644 --- a/crates/ui-contract/src/runtime/keys/nodes.rs +++ b/crates/ui-contract/src/runtime/keys/nodes.rs @@ -8,6 +8,9 @@ use egui::{Context, Id}; /// Makes `owner` the receiver of the requests that target the node of `node` (registered by `register_node`) and names /// `part` as the target: the row of a collection is a node of the row's component, and the collection acts on it. pub(crate) fn redirect_node(ctx: &Context, node: Id, owner: Id, part: PartRef) { + // Journaled after the `register_node` it amends, so a settled region's replay leaves the row's node with the + // collection, as a run does. + crate::runtime::replay::journal(ctx, || move |ctx: &Context| redirect_node(ctx, node, owner, part)); current(ctx, |stage| { if let Some(entry) = stage.nodes.get_mut(&node_key(node)) { entry.owner = owner;