Port · Calendar: a real exit clears the preview after a key
The calendar's grid clears its preview on leave, and ignores a leave that follows a key. gpui records the exit a key makes before the handler runs, so the guard swallowed it and a real exit afterwards had no change left to report: the stale day stayed the preview. The grid now listens independently of input, while its days keep the default, so a key is no leave and a real exit is. A test leaves the grid after an arrow, a letter and a month key. shaped()'s doc goes back to its one line; AGENTS.md keeps the why.
This commit is contained in:
1 parent
4c3ed1bbb9
commit
05bd22b7f0
5 files changed
+28
-5
No files matched your search
@@ -1,9 +1,9 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use gpui::{
|
||||
Animation, AnimationExt, App, ElementId, FocusHandle, FontWeight, InteractiveElement,
|
||||
IntoElement, ParentElement, RenderOnce, StatefulInteractiveElement, Styled, Window, div,
|
||||
prelude::*, transparent_black,
|
||||
Animation, AnimationExt, App, ElementId, FocusHandle, FontWeight, HoverListenerMode,
|
||||
InteractiveElement, IntoElement, ParentElement, RenderOnce, StatefulInteractiveElement, Styled,
|
||||
Window, div, prelude::*, transparent_black,
|
||||
};
|
||||
use jiff::{ToSpan, civil::Date};
|
||||
|
||||
@@ -328,6 +328,7 @@ impl RenderOnce for Calendar {
|
||||
.grid()
|
||||
.grid_cols(7)
|
||||
.gap_0p5()
|
||||
.hover_listener_mode(HoverListenerMode::InputModalityIndependent)
|
||||
.on_hover(move |over, window, cx| {
|
||||
if !*over && !window.last_input_was_keyboard() {
|
||||
leave.update(cx, |hover, cx| {
|
||||
|
||||
@@ -236,3 +236,24 @@ fn keys_keep_the_preview_under_a_resting_pointer(cx: &mut TestAppContext) {
|
||||
"the keyboard's day stays the preview"
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn leaving_the_grid_after_a_key_clears_the_preview(cx: &mut TestAppContext) {
|
||||
setup(cx);
|
||||
for key in ["right", "a", "pagedown"] {
|
||||
let (view, cx) = cx.add_window_view(|_, _| Watched { seen: Vec::new() });
|
||||
cx.update(|window, cx| window.focus_next(cx));
|
||||
cx.simulate_mouse_move(point(px(120.0), px(200.0)), None, Modifiers::none());
|
||||
cx.simulate_keystrokes(key);
|
||||
cx.update(|window, _| window.refresh());
|
||||
cx.run_until_parked();
|
||||
cx.simulate_mouse_move(point(px(700.0), px(480.0)), None, Modifiers::none());
|
||||
cx.update(|window, _| window.refresh());
|
||||
cx.run_until_parked();
|
||||
assert_eq!(
|
||||
view.read_with(cx, |view, _| view.seen.last().copied().flatten()),
|
||||
None,
|
||||
"after {key}, leaving the grid clears its preview"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user