From 679441e046cfaf0f5cca855186324ae81f6f533d Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 16:27:48 +0000 Subject: [PATCH] rc-chrome-w6: S-L187 edit signal (red round 1b) --- crates/ui-contract/src/contract/run.rs | 2 ++ crates/ui-contract/src/runtime/commands/board.rs | 1 + crates/ui-contract/src/runtime/commands/mod.rs | 3 +++ crates/ui-widgets/src/bars/items.rs | 4 +++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/ui-contract/src/contract/run.rs b/crates/ui-contract/src/contract/run.rs index b0899799a..60d9ac967 100644 --- a/crates/ui-contract/src/contract/run.rs +++ b/crates/ui-contract/src/contract/run.rs @@ -672,9 +672,11 @@ fn expand_for_overflow(ui: &mut Ui, at: ShowAt, rect: Rect, overflow: f32, rtl: } /// What the component senses itself: a disabled one that shows a reason on focus stays a Tab stop and senses nothing else. +/// One bound to an edit command keeps the focus where it is on a press, so the edit reaches the focused component. fn own_sense(e: &dyn ErasedPass<'_>, resolved: &Resolved, inert: bool) -> Sense { match (inert, resolved.enabled) { (true, _) => Sense::HOVER, + (false, true) if resolved.command.is_some_and(|command| command.edit) => e.sense().difference(Sense::TAKE_FOCUS).union(Sense::KEEP_FOCUS), (false, true) => e.sense(), (false, false) if steps::takes_focus(resolved) => Sense::HOVER | e.comp_sense().intersection(Sense::FOCUS), (false, false) => Sense::HOVER, diff --git a/crates/ui-contract/src/runtime/commands/board.rs b/crates/ui-contract/src/runtime/commands/board.rs index fe2337c09..0bf2d2efd 100644 --- a/crates/ui-contract/src/runtime/commands/board.rs +++ b/crates/ui-contract/src/runtime/commands/board.rs @@ -414,6 +414,7 @@ impl Board { marked: state.is_some_and(CommandState::is_marked), hint: state.and_then(|s| s.hint_ref().cloned()), kind: def.map_or(CommandKind::Command, |def| def.kind.clone()), + edit: self.registry.edit_of(&command.id).is_some(), command: command.clone(), instance, }; diff --git a/crates/ui-contract/src/runtime/commands/mod.rs b/crates/ui-contract/src/runtime/commands/mod.rs index a8566e64f..b6c261985 100644 --- a/crates/ui-contract/src/runtime/commands/mod.rs +++ b/crates/ui-contract/src/runtime/commands/mod.rs @@ -276,6 +276,9 @@ pub struct ResolvedCommand { pub hint: Option>, /// What the command is. pub kind: CommandKind, + /// The command is an edit a focused component takes as its own (it has an `EditCommand` link): a control bound to + /// it keeps the focus where it is on a press, so the edit reaches the focused component. + pub edit: bool, pub(crate) command: CommandRef, #[doc(hidden)] pub instance: Option, diff --git a/crates/ui-widgets/src/bars/items.rs b/crates/ui-widgets/src/bars/items.rs index 471a841f2..ce09f471d 100644 --- a/crates/ui-widgets/src/bars/items.rs +++ b/crates/ui-widgets/src/bars/items.rs @@ -383,7 +383,9 @@ impl Component for BarItems { slot(rect, axis, rtl, from, more_length) }); for &(index, cell) in &shown { - let part = cx.part(ITEM.at(index as u64), cell).sense(Sense::CLICK | Sense::FOCUS).focusable(); + // An edit command's item keeps the focus where it is, so the edit reaches the focused component. + let sense = if present[index].resolved.edit { Sense::CLICK | Sense::FOCUS | Sense::KEEP_FOCUS } else { Sense::CLICK | Sense::FOCUS }; + let part = cx.part(ITEM.at(index as u64), cell).sense(sense).focusable(); if display_of(&present[index]) == ItemDisplay::Icon { let resolved = &present[index].resolved; part.tooltip(match &resolved.chord {