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
@@ -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() {