From 05b8cc6d6044012a5eebdccc7430819a037933dd Mon Sep 17 00:00:00 2001 From: TO Date: Fri, 20 Nov 2026 21:32:01 +0100 Subject: [PATCH] Hide the hovered sheet when the grid scrolls (#73) A wheel scroll moves cards under a still pointer without a hover event, so the sheet could stay on a card no longer under it. The grid now forgets the hovered card on scroll; the next mouse move hovers the right one. Co-Authored-By: Claude Opus 5.5 --- crates/app/src/card_grid.rs | 7 +++++++ crates/app/src/page.rs | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/app/src/card_grid.rs b/crates/app/src/card_grid.rs index 88219fd..d2ae5ec 100644 --- a/crates/app/src/card_grid.rs +++ b/crates/app/src/card_grid.rs @@ -284,6 +284,13 @@ impl Render for CardGrid { .relative() .size_full() .key_context(CONTEXT) + // A wheel scroll moves cards under a still pointer without a hover event: the + // sheet of the card that was under it would stay. The next mouse move hovers again. + .on_scroll(cx.listener(|grid, _: &ScrollEvent, _, cx| { + if grid.hovered.take().is_some() { + cx.notify(); + } + })) .on_action(cx.listener(|grid, _: &NextCard, window, cx| grid.move_focus(1, window, cx))) .on_action( cx.listener(|grid, _: &PreviousCard, window, cx| grid.move_focus(-1, window, cx)), diff --git a/crates/app/src/page.rs b/crates/app/src/page.rs index 3aa78f2..30a627e 100644 --- a/crates/app/src/page.rs +++ b/crates/app/src/page.rs @@ -2030,6 +2030,28 @@ mod tests { ); } + #[gpui::test] + fn scrolling_the_grid_hides_the_sheet_of_the_card_that_was_under_the_pointer( + cx: &mut TestAppContext, + ) { + let (page, cx) = open_page_in_season(cx); + let cx = &mut { cx }; + show(&page, cx, statistics(1, 170, sheet_champions(170))); + draw(cx); + let over = center(cx, "card-1"); + cx.simulate_mouse_move(over, None, Modifiers::none()); + draw(cx); + assert_eq!(sheet_ids(cx, 170), [1]); + + cx.simulate_event(ScrollEvent { + position: over, + delta: ScrollDelta::Pixels(point(px(0.), px(-20.))), + ..Default::default() + }); + draw(cx); + assert!(sheet_ids(cx, 170).is_empty(), "the sheet stuck to its card"); + } + fn press(cx: &mut VisualTestContext, keys: &str) { cx.simulate_keystrokes(keys); draw(cx);