Mail · a focused star keeps Space and Enter; so does Unpin

A button in a SelectableList row now stops Space and Enter at its box
on key down, so the list no longer toggles its selection before the
button acts. The mail star and the pinned messages' Unpin, which had
the same fault, both do.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-26 23:45:22 -04:00
1 parent 7d20567921
commit d2379bc911
5 files changed
+38 -1

No files matched your search

+8
View File
@@ -166,6 +166,14 @@ impl MailItem {
window.prevent_default();
cx.stop_propagation();
})
.on_key_down(|event, _, cx| {
let key = event.keystroke.key.as_str();
if matches!(key, "space" | "enter")
&& !event.keystroke.modifiers.modified()
{
cx.stop_propagation();
}
})
.on_click(move |_, window, cx| {
log::info!("mail {key}: star {}", !starred);
set(!starred, window, cx)
+10
View File
@@ -187,6 +187,16 @@ fn a_star_toggles_and_leaves_the_selection(cx: &mut TestAppContext) {
assert_eq!(heard(&host, cx), ["star m3 false"]);
}
#[gpui::test]
fn space_on_a_star_stars_and_leaves_the_selection(cx: &mut TestAppContext) {
let (host, cx) = mailing(mails, cx);
tab_to(2, cx);
press("space", cx);
tab_to(2, cx);
press("enter", cx);
assert_eq!(heard(&host, cx), ["star m1 true", "star m1 true"]);
}
#[gpui::test]
fn no_mail_says_so_and_takes_no_tab_stop(cx: &mut TestAppContext) {
let (_, cx) = mailing(
+8
View File
@@ -90,6 +90,14 @@ impl RenderOnce for PinnedMessages {
div()
.debug_selector(move || format!("unpin {named}"))
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
.on_key_down(|event, _, cx| {
let key = event.keystroke.key.as_str();
if matches!(key, "space" | "enter")
&& !event.keystroke.modifiers.modified()
{
cx.stop_propagation();
}
})
.child(
IconButton::new(
(self.id.clone(), format!("unpin-{key}")),
+11
View File
@@ -221,6 +221,17 @@ fn a_press_on_unpin_unpins_and_opens_nothing(cx: &mut TestAppContext) {
);
}
#[gpui::test]
fn space_on_unpin_unpins_and_opens_nothing(cx: &mut TestAppContext) {
let (host, cx) = pinning(cx);
tab_to(2, cx);
press("space", cx);
assert_eq!(
host.read_with(cx, |host, _| host.asked.clone()),
["unpin newer"]
);
}
#[test]
#[should_panic(expected = "pin a twice")]
fn a_message_is_pinned_once() {