From 0d650f4064f1918a7c7aae0002b60488ebb174bd Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 18 Nov 2026 09:16:40 -0500 Subject: [PATCH] red round 3 (fw-apps): fixes for fw-run-4 (runs/fw-run-4/fw-apps.md); committed by the lead Co-Authored-By: Claude Opus 5.5 --- crates/print/src/ui/dialog.rs | 6 +++--- crates/review/tests/it/comments.rs | 3 ++- crates/text/src/ui/find/bar.rs | 11 +++-------- crates/text/tests/it/find_bar.rs | 5 ----- crates/ui-contract/src/runtime/focus.rs | 2 +- crates/ui-contract/src/runtime/focus/nav.rs | 3 ++- crates/ui-contract/src/testing/suite/size.rs | 4 ---- 7 files changed, 11 insertions(+), 23 deletions(-) diff --git a/crates/print/src/ui/dialog.rs b/crates/print/src/ui/dialog.rs index 0e83c9dc6..140298191 100644 --- a/crates/print/src/ui/dialog.rs +++ b/crates/print/src/ui/dialog.rs @@ -18,7 +18,7 @@ use craft_ui::notices::{Notice, NoticeLayout}; use craft_ui::patterns::form_dialogs::{ DialogFields, FieldValue, FormDialog, HostRequests, PagerStep, PanePager, Param, ParamRows, set_color_field, set_param_field, }; -use craft_ui::primitives::{ContentPainterCx, TextRun, fill_polygon}; +use craft_ui::primitives::{ContentPainterCx, TextRun, Wrap, fill_polygon}; use craft_ui::runtime::env::{Env, Label}; use craft_ui::runtime::focus::{ActivateKeys, KeepKeys, KeyUse}; use craft_ui::runtime::overlay::CloseReason; @@ -423,7 +423,7 @@ impl Component for PrintPreview<'_> { // A message takes the lines it wraps to at this width, so a larger text size grows the part instead of // overflowing it. let message = match &self.sheet.content { - SheetContent::Message(message) => cx.layout_at(&TextRun::new(cx.env.resolve(message).as_str()), width).size().y, + SheetContent::Message(message) => cx.layout_at(&TextRun::new(cx.env.resolve(message).as_str()).wrap(Wrap::Wrap), width).size().y, _ => 0.0, }; Vec2::new(width, (width * aspect).max(message)) @@ -489,7 +489,7 @@ impl Component for PrintPreview<'_> { let painter = ui.content_painter(cx); painter.surface(cx.rect, SurfaceKind::Well, Corners::None); let shown = cx.env.resolve(message); - let run = TextRun::new(shown.as_str()).color(style.ink); + let run = TextRun::new(shown.as_str()).wrap(Wrap::Wrap).color(style.ink); centred_text(&painter, &run, cx.rect.center(), cx.rect.width()); return; } diff --git a/crates/review/tests/it/comments.rs b/crates/review/tests/it/comments.rs index 3b347155c..15a1b9067 100644 --- a/crates/review/tests/it/comments.rs +++ b/crates/review/tests/it/comments.rs @@ -293,7 +293,8 @@ fn long_list() -> (Rc>>, Rc FindBar<'a> { .select_all(to_query) .show(ui); if to_query { - let taken = focus::request(ui.ctx(), FocusTarget::Id(edit.response.id)); - eprintln!( - "DIAG asking_for_the_bar_again_selects_its_query_unless_a_composition_runs: request taken {taken} has_focus {} field {:?} egui focused {:?}", - edit.response.has_focus(), - edit.response.id, - ui.ctx().memory(|memory| memory.focused()) - ); + focus::request(ui.ctx(), FocusTarget::Id(edit.response.id)); // Asking again each run until the field holds focus keeps the request across the measuring run. - if edit.response.has_focus() + // The field's focus sits on its text part, so the egui response of the field never reports it. + if focus::is_focused(ui.ctx(), edit.response.id) && let Some(state) = state.as_deref_mut() { state.served(); diff --git a/crates/text/tests/it/find_bar.rs b/crates/text/tests/it/find_bar.rs index c3166e825..b7119acaf 100644 --- a/crates/text/tests/it/find_bar.rs +++ b/crates/text/tests/it/find_bar.rs @@ -43,11 +43,6 @@ impl Bar { self.discard.set(rerun); self.state.borrow_mut().open(); self.fixture.frame(Vec::new()).settle(); - eprintln!( - "DIAG asking_for_the_bar_again_selects_its_query_unless_a_composition_runs: rerun {rerun} opening {} focused {:?}", - self.state.borrow().is_opening(), - self.fixture.focused() - ); assert!(!self.state.borrow().is_opening(), "the query field took the focus request"); } diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index 8448fdb84..6335bff58 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -622,7 +622,7 @@ pub(crate) fn is_row_child(ctx: &Context, stop: &Stop) -> bool { /// Whether the focus stop is the component `id`: the focused member or item of its arena, or a root that /// holds focus while none of its members is the stop. A root's own focused part counts as the root. -pub(crate) fn is_focused(ctx: &Context, id: Id) -> bool { +pub fn is_focused(ctx: &Context, id: Id) -> bool { focused_stop(ctx).is_some_and(|(focused, _)| focused == id) } diff --git a/crates/ui-contract/src/runtime/focus/nav.rs b/crates/ui-contract/src/runtime/focus/nav.rs index 61b152f7f..3e58dbd1d 100644 --- a/crates/ui-contract/src/runtime/focus/nav.rs +++ b/crates/ui-contract/src/runtime/focus/nav.rs @@ -146,7 +146,8 @@ impl Lists<'_> { fn arrival(&self, group: &super::Group) -> Option { let mut group = *group; for _ in 0..MAX_NESTING { - let selected = group.selected.and_then(|key| self.stops.iter().find(|rec| rec.stop.key() == key && self.slot_in(rec, group.id).is_some())); + let selected = + group.selected.and_then(|key| self.stops.iter().find(|rec| rec.stop.key() == key && self.slot_in(rec, group.id).is_some())); if let Some(rec) = selected { return Some(rec.clone()); } diff --git a/crates/ui-contract/src/testing/suite/size.rs b/crates/ui-contract/src/testing/suite/size.rs index 3862f47bc..a17c1c4ba 100644 --- a/crates/ui-contract/src/testing/suite/size.rs +++ b/crates/ui-contract/src/testing/suite/size.rs @@ -141,10 +141,6 @@ fn text_size_from(story: &Story, base: Shot) -> Result<(), String> { // A run the component painted elided is shortened by design and keeps its full text in the access name // (the elision rule checks that), so it is not cut; it must still stay inside its part. if !grown.keeps(same.rect, same.clip) { - eprintln!( - "DIAG {}: variant {name} base run {:?} clip {:?} grown run {:?} clip {:?} elided {} shown {:?}", - story.name, run.rect, run.clip, same.rect, same.clip, same.elided, grown.shown - ); return Err(format!("{}: under {name} the text `{}` leaves its part", story.name, run.text)); } }