From 797b3b4bb1870f8fa7e4e45c1886d59fe3a19675 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 12 Nov 2026 09:04:28 +0000 Subject: [PATCH] Suite: the scroll frame case reads the rows in view, not the lead and anchor kept built out of view --- .../ui-contract/src/testing/suite/collection.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/ui-contract/src/testing/suite/collection.rs b/crates/ui-contract/src/testing/suite/collection.rs index 754953ef5..04ddacd13 100644 --- a/crates/ui-contract/src/testing/suite/collection.rs +++ b/crates/ui-contract/src/testing/suite/collection.rs @@ -341,20 +341,28 @@ pub(super) fn long_collection_builds_rows_within_the_room_only(subject: &Subject Ok(()) } -/// One wheel step moves the rows and the frame it happens in shows rows over the whole viewport. +/// One wheel step moves the rows and the frame it happens in shows rows over the whole viewport. The rows that +/// meet the viewport are the ones shown: a kept row (the lead, the anchor) stays built out of view. pub(super) fn scroll_shows_rows_in_the_same_frame(subject: &Subject) -> Result<(), String> { if !is_items(subject) { return Ok(()); } + let in_view = |fixture: &Fixture, container: &Target| { + let mut shown = rows(fixture, container.node); + shown.retain(|row| row.rect.intersects(container.rect)); + shown + }; for story in &subject.stories { - let Some((mut fixture, container, shown)) = with_rows(story, 3) else { continue }; - let Some((_, size)) = position_in_set(&fixture, shown[0].node) else { continue }; + let Some((mut fixture, container, _)) = with_rows(story, 3) else { continue }; + let shown = in_view(&fixture, &container); + let Some(first) = shown.first() else { continue }; + let Some((_, size)) = position_in_set(&fixture, first.node) else { continue }; if shown.len() >= size { continue; } fixture.frame(vec![crate::testing::pointer::moved(container.rect.center())]); fixture.frame(vec![crate::testing::pointer::wheel(-3.0 * shown[0].rect.height())]); - let now = rows(&fixture, container.node); + let now = in_view(&fixture, &container); let (Some(top), Some(bottom)) = (now.first(), now.last()) else { return Err(format!("{}: no row is shown in the frame of the scroll", story.name)); };