diff --git a/crates/ui-contract/src/runtime/access/emit.rs b/crates/ui-contract/src/runtime/access/emit.rs index ac4172e370..f6ab1b5d36 100644 --- a/crates/ui-contract/src/runtime/access/emit.rs +++ b/crates/ui-contract/src/runtime/access/emit.rs @@ -328,7 +328,7 @@ pub(crate) fn report(ctx: &Context, own: &Own<'_>) { description: spec.description.clone(), unnamed, inner_stop: None, - focusable: own.focusable, + focusable: own.focusable || crate::runtime::focus::has_reachable_stop(ctx, own.id), disabled: !own.enabled, }, ); diff --git a/crates/ui-contract/src/runtime/access/scope.rs b/crates/ui-contract/src/runtime/access/scope.rs index 0900089044..8962ac4a0c 100644 --- a/crates/ui-contract/src/runtime/access/scope.rs +++ b/crates/ui-contract/src/runtime/access/scope.rs @@ -166,7 +166,7 @@ pub(crate) struct ScopeNode { pub unnamed: Option, /// The first focus stop inside a control that has none of its own: where a click on its label moves focus. pub inner_stop: Option, - /// The node takes key focus itself. + /// The control takes key focus, at its own stop or at a part's (a segmented control's segments). pub focusable: bool, /// The control is disabled: a label that names only disabled controls is disabled too. pub disabled: bool, diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index 1635da3c2c..96815b646e 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -339,6 +339,12 @@ pub(crate) fn targets(ctx: &Context) -> [Option; 2] { [focused_stop(ctx).map(|key| key.0), with(ctx, |state| state.revealed.map(|key| key.0))] } +/// Whether the component `id` registered a stop this pass that Tab or a request can reach, its own or one of its +/// parts': a segmented control's stops are its segments. A press-only stop (the selection of a display text) is not one. +pub(crate) fn has_reachable_stop(ctx: &Context, id: Id) -> bool { + with(ctx, |state| state.stops.iter().any(|rec| rec.stop.id == id && !rec.stop.press_only)) +} + /// Where a request for the component `id` goes when it has no stop of its own: the first stop registered since /// `from` (a `stop_count`), which a component inside it holds. pub(crate) fn first_stop_inside(ctx: &Context, id: Id, from: usize) -> Option { diff --git a/crates/ui-contract/src/testing/suite/variants.rs b/crates/ui-contract/src/testing/suite/variants.rs index a2b9a2caa8..e585ed2ef0 100644 --- a/crates/ui-contract/src/testing/suite/variants.rs +++ b/crates/ui-contract/src/testing/suite/variants.rs @@ -165,6 +165,7 @@ fn rtl_from(story: &Story, ltr: &Fixture) -> Result<(), String> { let rtl = shown_in(story, Direction::Rtl); let own = (root_target(ltr).rect, root_target(&rtl).rect); if (own.0.width() - own.1.width()).abs() > 0.5 { + eprintln!("DIAG rf-widgets rtl: {}: ltr rect {:?} rtl rect {:?}", story.name, own.0, own.1); return Err(format!("{}: the component's width differs between directions", story.name)); } // Each node is reflected within the component's own rect, then carried to the component's rect in the other diff --git a/crates/ui-widgets/src/list/row/show.rs b/crates/ui-widgets/src/list/row/show.rs index bf32b3682b..e481328349 100644 --- a/crates/ui-widgets/src/list/row/show.rs +++ b/crates/ui-widgets/src/list/row/show.rs @@ -162,6 +162,16 @@ impl Component for ListRow<'_> { }; let label = label.max(self.below_width(sizes)); let own = probe.ideal_width - sizes.min_label + label.max(sizes.min_label) + self.indent_full(sizes); + if !self.label_spans.is_empty() { + let spans = cx.layout(&self.label_run(cx.resolved.label).role(cx.style.text.role)).size().x; + let plain = cx.layout(&TextRun::new(cx.resolved.label).role(cx.style.text.role)).size().x; + let pieces: Vec = + self.label_spans.iter().map(|span| cx.layout(&TextRun::new(span.text.as_ref()).role(cx.style.text.role)).size().x).collect(); + eprintln!( + "DIAG rf-widgets list_row_match_highlight: rtl {rtl} proposal {:?} room {:?} spans {spans} plain {plain} pieces {pieces:?} label {label} ideal {} min {} own {own}", + cx.proposal, cx.room, probe.ideal_width, probe.min_width + ); + } if cx.proposal == Proposal::Ideal { self.report_cell_widths(cx, own); }