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 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-11-20 21:32:01 +01:00
1 parent 796fae11b7
commit 05b8cc6d60
2 files changed
+29

No files matched your search

+7
View File
@@ -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)),
+22
View File
@@ -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);