red round 1 (fw-lists): fixes for fw-run-2 (see runs/fw-run-2/fw-lists.md); committed by the lead

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. TaylorandClaude Opus 5.5 committed 2026-11-18 08:49:42 -05:00
1 parent c968deda51
commit f7c52bf55e
6 files changed
+47 -13

No files matched your search

+9 -1
View File
@@ -3,6 +3,7 @@
use super::{CellStatus, HueTarget, ListRow, RowInk, TrailingFace, TrailingPart};
use crate::contract::Show as _;
use crate::primitives::IconSpec;
use crate::runtime::env::Env;
use crate::style::DataColor;
use crate::testing::{Drive, StoryData, StoryOutput, show_as_only_item, story};
use craft_behavior::{ColumnKey, IconId};
@@ -91,10 +92,17 @@ fn list_row_status_cell(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
const WARNINGS: ColumnKey = ColumnKey::new("warnings");
let (left, width, height) = (ui.cursor().min.x, ui.available_width(), ui.spacing().interact_size.y);
let split = left + width * 0.4;
let cells = [
let mut cells = [
(NAME, Rect::from_min_max(Pos2::new(left, 0.0), Pos2::new(split, height))),
(WARNINGS, Rect::from_min_max(Pos2::new(split, 0.0), Pos2::new(left + width, height))),
];
// The columns are screen rects: under right-to-left the name column is at the right.
if Env::of(ui).view().direction().is_rtl() {
for (_, cell) in &mut cells {
*cell =
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));
}
}
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");
+6 -3
View File
@@ -7,8 +7,8 @@ use super::{
};
use crate::buttons::Button;
use crate::contract::{
Bind, CollectionEvent, ColumnSpec, Entry, Props as _, Show as _, ShowCollection as _, ShowContainer as _, ToggleColumn, ToggleEdit, WordSetCx as _,
request_rename,
Bind, CollectionEvent, ColumnSpec, Entry, Props as _, Show as _, ShowCollection as _, ShowContainer as _, ToggleColumn, ToggleEdit,
WordSetCx as _, request_rename,
};
use crate::layout_components::Stack;
use crate::menu::Menu;
@@ -483,7 +483,10 @@ fn list_rename_while_filtered(ui: &mut Ui, data: &mut StoryData) -> StoryOutput
const NOTES: usize = 2;
let id = egui::Id::new("list_rename_while_filtered");
let names = data.value("names", vec![String::from("Chapter 1"), String::from("Chapter 2"), String::from("Notes")]).clone();
if crate::contract::clicked(&Button::new("Rename Notes").show(ui)) {
// The button sits at the start of the list's width, which is the right under right-to-left.
let start = if Env::of(ui).view().direction().is_rtl() { egui::Align::Max } else { egui::Align::Min };
let button = ui.with_layout(egui::Layout::top_down(start), |ui| Button::new("Rename Notes").show(ui)).inner;
if crate::contract::clicked(&button) {
request_rename(ui.ctx(), id, &NOTES);
}
let out = List::<usize>::new("Bookmarks")
@@ -235,13 +235,15 @@ fn tile_grid_insert_gaps(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
StoryOutput::from(out).readout(readout)
}
/// A middle click in the grid latches auto-scroll, and the pointer below the latch point scrolls the grid down.
/// A middle click in the grid latches auto-scroll, and the pointer below the latch point scrolls the grid down; Escape
/// ends the latch, so the driven story rests.
fn middle_scroll(fixture: &mut Fixture) {
let at = fixture.shown().center();
fixture.frame(vec![pointer::moved(at)]);
fixture.frame(vec![pointer::middle(at, true)]);
fixture.frame(vec![pointer::middle(at, false)]);
fixture.frame(vec![pointer::moved(at + Vec2::new(0.0, 60.0))]).idle(4);
fixture.key(Key::Escape, Modifiers::NONE).settle();
}
/// The middle button latches auto-scroll instead of panning: the items step paints the latch mark at the press point
+12 -8
View File
@@ -1135,7 +1135,10 @@ fn a_secondary_click_on_a_trailing_part_opens_the_row_menu() {
fixture.frame(vec![pointer::secondary(button, false)]).settle();
let events = seen.borrow();
assert!(events.iter().any(|event| matches!(event, CollectionEvent::ContextMenu(request) if request.key == 1)), "the row's menu: {events:?}");
assert!(!events.iter().any(|event| matches!(event, CollectionEvent::Item(_, RowEvent::Trailing { .. }))), "the button is not pressed: {events:?}");
assert!(
!events.iter().any(|event| matches!(event, CollectionEvent::Item(_, RowEvent::Trailing { .. }))),
"the button is not pressed: {events:?}"
);
}
/// A status cell's tip is the cell's description, and its action is reached from the keyboard: into the list, onto
@@ -1220,7 +1223,7 @@ fn a_collection_reports_the_row_under_the_pointer() {
fn painted_at(shapes: &[egui::Shape], text: &str) -> Option<egui::Rect> {
shapes.iter().find_map(|shape| match shape {
egui::Shape::Vec(inner) => painted_at(inner, text),
egui::Shape::Text(shown) if shown.galley.text() == text => Some(shown.visual_bounding_rect()),
egui::Shape::Text(shown) if shown.galley.text() == text => Some(shown.galley.rect.translate(shown.pos.to_vec2())),
_ => None,
})
}
@@ -1339,8 +1342,7 @@ fn a_filter_matches_any_of_a_rows_texts_and_keeps_the_ancestors_of_a_match() {
tree.room(Vec2::new(300.0, 200.0));
tree.settle();
let titles: Vec<&str> = BRANCHES.iter().map(|(title, _)| *title).collect();
let cases: [(&str, &[&str]); 3] =
[("istanbul", &[BRANCHES[0].0]), ("KIŞ", &[BRANCHES[0].0, BRANCHES[1].0]), ("izmir", &[])];
let cases: [(&str, &[&str]); 3] = [("istanbul", &[BRANCHES[0].0]), ("KIŞ", &[BRANCHES[0].0, BRANCHES[1].0]), ("izmir", &[])];
for (asked, kept) in cases {
tree_query.set(asked);
tree.settle();
@@ -1368,10 +1370,12 @@ fn a_row_in_rename_stays_listed_while_the_filter_excludes_it() {
fixture.room(Vec2::new(300.0, 200.0));
fixture.settle();
assert_eq!(*shown.borrow(), [0], "the query keeps the first row alone");
request_rename(fixture.ctx(), list_id(), &2);
request_rename(fixture.ctx(), list_id(), &2_usize);
fixture.settle();
assert!(
seen.borrow().iter().any(|event| matches!(event, CollectionEvent::Rename(EditEvent::Begin { before: Mixed::Same(rename), .. }) if rename.key == 2)),
seen.borrow()
.iter()
.any(|event| matches!(event, CollectionEvent::Rename(EditEvent::Begin { before: Mixed::Same(rename), .. }) if rename.key == 2)),
"the rename of the excluded row begins: {:?}",
seen.borrow()
);
@@ -1410,7 +1414,7 @@ fn a_rename_editor_selects_the_name_once_keeps_the_caret_and_escape_cancels() {
.collect()
};
request_rename(fixture.ctx(), list_id(), &0);
request_rename(fixture.ctx(), list_id(), &0_usize);
fixture.settle();
let field = egui_focused(fixture.ctx()).expect("the rename field takes the focus");
assert_eq!(caret(fixture.ctx(), field), Some(name.chars().count()), "the field opens with the whole name selected");
@@ -1420,7 +1424,7 @@ fn a_rename_editor_selects_the_name_once_keeps_the_caret_and_escape_cancels() {
assert!(edits(&seen).is_empty(), "Escape ends the rename with no edit: {:?}", seen.borrow());
assert_ne!(egui_focused(fixture.ctx()), Some(field), "the rename field is gone");
request_rename(fixture.ctx(), list_id(), &0);
request_rename(fixture.ctx(), list_id(), &0_usize);
fixture.settle();
fixture.type_text("Özet").key(Key::Enter, Modifiers::NONE).settle();
assert_eq!(edits(&seen), [(0, String::from("Özet"))], "typing replaces the whole multibyte name");
@@ -54,6 +54,13 @@ fn an_icon_row_is_one_stop_in_the_menu_left_and_right_move_between_its_icons_and
let open = |fixture: &mut Fixture| {
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,
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");
// Every walk below starts on the first row.
request(fixture.ctx(), FocusTarget::Id(rows.get().group.expect("the first row is shown")));
@@ -112,6 +112,16 @@ fn a_wheel_zoom_keeps_the_tile_under_the_pointer_in_place() {
let start = zoom.get();
fixture.frame(vec![pointer::zoom_wheel(120.0)]).settle();
assert!(zoom.get() != start, "the wheel zoom moved the bound value from {start}");
{
let seen = shown.borrow();
let mut keys: Vec<usize> = seen.tiles.keys().copied().collect();
keys.sort_unstable();
eprintln!(
"DIAG a_wheel_zoom_keeps_the_tile_under_the_pointer_in_place: key {key} before {before:?} zoom {start} -> {} view {:?} shown {keys:?}",
zoom.get(),
seen.view
);
}
let after = shown.borrow().tile(key);
assert!((after.top() - before.top()).abs() <= 1.0, "the tile under the pointer keeps its top: {before:?} to {after:?}");