From 3ca5e9ef77b69f33a45c80df4450ea31fb98c7eb Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 18 Nov 2026 09:04:07 -0500 Subject: [PATCH] red round 2 (fw-lists): fixes for fw-run-3 (runs/fw-run-3/fw-lists.md); L-198 applied in fw-lists; committed by the lead Co-Authored-By: Claude Opus 5.5 --- crates/ui-contract/src/contract/items/hooks.rs | 9 +++++++++ crates/ui-contract/src/contract/items/press.rs | 6 +++--- crates/ui-contract/src/testing/suite/size.rs | 4 ++++ crates/ui-widgets/src/list/stories.rs | 5 +++++ crates/ui-widgets/tests/it/list.rs | 2 +- crates/ui-widgets/tests/it/menu/icon_row.rs | 9 ++++----- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/crates/ui-contract/src/contract/items/hooks.rs b/crates/ui-contract/src/contract/items/hooks.rs index 521378417..6dd2793a4 100644 --- a/crates/ui-contract/src/contract/items/hooks.rs +++ b/crates/ui-contract/src/contract/items/hooks.rs @@ -891,6 +891,15 @@ impl ItemsHooks<'_, '_, C> { let item = sub(id, ("key", key_hash(&self.source.key(at)))); placed.note((named, (false, true)), item, Vec2::new(0.0, row.min.y), row.size()); } + // A zoom reflows the rows, so the anchor's row may lie outside the rows this pass built: the layout still + // knows where it is. + if let (Some(child), None) = (named, placed.anchor) { + let away = (0..source.len()).filter(|&at| scrolling(at)).find(|&at| sub(id, ("key", key_hash(&source.key(at)))) == child); + if let Some(at) = away { + let row = layout.rect(at, offset); + placed.note((named, (false, true)), child, Vec2::new(0.0, row.min.y), row.size()); + } + } let moved = Vec2::new(0.0, (self.offset - self.offset_at_read) as f32); let room = (Vec2::new(0.0, self.offset as f32), Vec2::new(0.0, (self.max_offset(view.y) - self.offset) as f32)); if let Some(shift) = lazy::follow(&mut self.anchor, &placed, moved, view, room, (false, true)) { diff --git a/crates/ui-contract/src/contract/items/press.rs b/crates/ui-contract/src/contract/items/press.rs index 8b9adb316..0464a1719 100644 --- a/crates/ui-contract/src/contract/items/press.rs +++ b/crates/ui-contract/src/contract/items/press.rs @@ -277,14 +277,14 @@ impl ItemsHooks<'_, '_, C> { _ => {} } // A secondary release on a row asks for its menu (9.2 rule 3); the row joins the selection unless it is in it. - // Something over the collection, or a part of a row or of the collection that takes presses and is under the - // pointer, keeps the request away; a part that picks its item (a thumbnail) is the row's, and the request names + // Something over the collection, or a part of a row or of the collection that takes the secondary click itself + // (its own menu, L-198) and is under the pointer, keeps the request away; a part that picks its item (a thumbnail) is the row's, and the request names // it. let released = crate::runtime::pointer::frame(&ctx); let hover = crate::primitives::sensing::read_outcome(&ctx, ArenaId::new(cx.core.id)).hover; let menu_at = if released.release == Some(craft_behavior::PointerButton::Secondary) && cx.core.response.hovered() - && hover.find(|hit| hit.part.is_some() && hit.sense.takes_press() && !hit.sense.contains(Sense::PICKS_ITEM)).is_none() + && hover.find(|hit| hit.part.is_some() && hit.sense.contains(Sense::CONTEXT_CLICK) && !hit.sense.contains(Sense::PICKS_ITEM)).is_none() { released.pos.filter(|pos| rect.contains(xf.map_or(*pos, |map| map.to_layer(*pos)))) } else { diff --git a/crates/ui-contract/src/testing/suite/size.rs b/crates/ui-contract/src/testing/suite/size.rs index a17c1c4ba..1d12f3c0e 100644 --- a/crates/ui-contract/src/testing/suite/size.rs +++ b/crates/ui-contract/src/testing/suite/size.rs @@ -141,6 +141,10 @@ 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 suite ListRow reads text-size {}: {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)); } } diff --git a/crates/ui-widgets/src/list/stories.rs b/crates/ui-widgets/src/list/stories.rs index 862447d91..b31dbcc6e 100644 --- a/crates/ui-widgets/src/list/stories.rs +++ b/crates/ui-widgets/src/list/stories.rs @@ -103,6 +103,11 @@ fn list_row_status_cell(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { Rect::from_min_max(Pos2::new(2.0 * left + width - cell.max.x, cell.min.y), Pos2::new(2.0 * left + width - cell.min.x, cell.max.y)); } } + eprintln!( + "DIAG suite ListRow variants rtl list_row_status_cell: rtl {} left {left} width {width} cursor {:?} cells {cells:?}", + Env::of(ui).view().direction().is_rtl(), + ui.cursor() + ); let status = CellStatus::new(Tone::Warn, "2 warnings") .tip("The file has form fields that will be flattened.\nIts bookmarks point to pages that are not kept.") .action("Details"); diff --git a/crates/ui-widgets/tests/it/list.rs b/crates/ui-widgets/tests/it/list.rs index 7d1525576..64f3aa7d6 100644 --- a/crates/ui-widgets/tests/it/list.rs +++ b/crates/ui-widgets/tests/it/list.rs @@ -1396,7 +1396,7 @@ fn a_rename_editor_selects_the_name_once_keeps_the_caret_and_escape_cancels() { let held = seen.clone(); let mut fixture = Fixture::new(move |ui| { let keys = [0_usize, 1]; - let source = keyed(&keys, |key: &usize| *key); + let source = keyed(&keys, |key: &usize| *key).with_text(|key| std::borrow::Cow::Borrowed(SHEETS[*key])); let out = List::new("Sheets").id(list_id()).rename(true).show_items(ui, &source, &mut |key, _| ListRow::new(SHEETS[*key])); held.borrow_mut().extend(out.events); }); diff --git a/crates/ui-widgets/tests/it/menu/icon_row.rs b/crates/ui-widgets/tests/it/menu/icon_row.rs index 1dbe84ac1..8b3efb91a 100644 --- a/crates/ui-widgets/tests/it/menu/icon_row.rs +++ b/crates/ui-widgets/tests/it/menu/icon_row.rs @@ -49,16 +49,15 @@ fn an_icon_row_is_one_stop_in_the_menu_left_and_right_move_between_its_icons_and } }); fixture.settle(); - let target = fixture.by_label("Canvas").expect("the menu's target"); - fixture.click(&target); let open = |fixture: &mut Fixture| { + // A click does not focus a button, and Shift+F10 asks the focused component for its menu. + request(fixture.ctx(), FocusTarget::Id(rows.get().target.expect("the menu's target is shown"))); + fixture.settle(); fixture.key(Key::F10, Modifiers::SHIFT); fixture.settle(); eprintln!( - "DIAG an_icon_row_is_one_stop_in_the_menu_left_and_right_move_between_its_icons_and_a_pick_closes_the_chain: target {:?} focused {:?} context request {:?} group shown {}", - rows.get().target, + "DIAG an_icon_row_is_one_stop_in_the_menu_left_and_right_move_between_its_icons_and_a_pick_closes_the_chain: focused {:?} group shown {}", fixture.focused_stop(), - rows.get().target.and_then(|id| craft_ui::testing::focus::context_request(fixture.ctx(), id)), fixture.by_label("Group").is_some() ); assert!(fixture.by_label("Ungroup").is_some(), "Shift+F10 opens the context menu");