T23d round 1 fix

- the conversation list reads the zone through format::system_zone, which
  fails loud; the gallery expects the system zone
- Combobox opens with its cursor on its value, MultiSelect on the first
  row ticked; tests for all three lists open r25 of thirty in view
- AGENTS: the zone rule; lists open on their choice
This commit is contained in:
ZacharyZhang-NY committed 2026-09-26 07:42:45 -04:00
1 parent 280d49a96c
commit e46974f055
8 files changed
+87 -26

No files matched your search

+12
View File
@@ -158,6 +158,18 @@ impl RenderOnce for Combobox {
};
let rows = Rc::new(matching(&self.choices, query));
let open = focused && !typing.read(cx).dismissed && !rows.is_empty();
if open != picker.read(cx).open {
let chosen = self.selected.as_ref().and_then(|value| {
rows.iter()
.position(|row| !row.disabled && row.value == *value)
});
picker.update(cx, |picker, _| {
picker.open = open;
if let Some(at) = chosen.filter(|_| open) {
picker.highlighted = at;
}
});
}
let kept = picker.read(cx).highlighted;
let highlighted = if rows.get(kept).is_some_and(|row| !row.disabled) {
kept
+4 -1
View File
@@ -79,7 +79,10 @@ impl RenderOnce for MultiSelect {
picker.update(cx, |picker, _| picker.open = false);
}
let (choices, selected) = (Rc::new(self.choices), Rc::new(self.selected));
let start = step(&choices, choices.len() - 1, 1);
let start = choices
.iter()
.position(|choice| !choice.disabled && selected.contains(&choice.value))
.unwrap_or_else(|| step(&choices, choices.len() - 1, 1));
if picker.read(cx).highlighted >= choices.len() {
picker.update(cx, |picker, _| picker.highlighted = start);
}
+60 -21
View File
@@ -87,38 +87,59 @@ fn select_opens_moves_and_picks_from_the_keyboard(cx: &mut TestAppContext) {
assert_eq!(view.read_with(cx, |view, _| view.chosen.clone()), "b");
}
/// A select of thirty rows, low in the window, and the rows it picked.
/// Which list of thirty rows a test opens.
#[derive(Clone, Copy)]
enum Kind {
Select,
Combobox,
Multi,
}
/// A list of thirty rows with r25 chosen, low in the window, and what each press picked.
struct Long {
chosen: SharedString,
picks: Vec<SharedString>,
kind: Kind,
field: Entity<TextInput>,
picks: Vec<String>,
}
impl Render for Long {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let view = cx.entity();
let rows = (0..30).map(|ix| Choice::new(format!("r{ix:02}"), format!("Row {ix:02}")));
div().pt(px(200.0)).w(px(240.0)).child(
Select::new("long", rows)
.selected(self.chosen.clone())
.on_change(move |value, _, cx| {
view.update(cx, |view, cx| {
view.chosen = value.clone();
view.picks.push(value.clone());
cx.notify();
})
}),
)
let view = cx.entity();
let note = move |pick: String, cx: &mut gpui::App| {
view.update(cx, |view, cx| {
view.picks.push(pick);
cx.notify();
})
};
let list = match self.kind {
Kind::Select => Select::new("long", rows)
.selected("r25")
.on_change(move |value, _, cx| note(value.to_string(), cx))
.into_any_element(),
Kind::Combobox => Combobox::new("long", &self.field, rows)
.selected("r25")
.on_change(move |value, _, cx| note(value.to_string(), cx))
.into_any_element(),
Kind::Multi => MultiSelect::new("long", rows)
.selected([SharedString::from("r25")])
.on_change(move |next, _, cx| note(next.join(","), cx))
.into_any_element(),
};
div().pt(px(200.0)).w(px(240.0)).child(list)
}
}
#[gpui::test]
fn a_long_list_opens_with_its_choice_in_view(cx: &mut TestAppContext) {
/// Opens the list with a press on its field, then presses the row at its foot.
fn press_the_foot(kind: Kind, cx: &mut TestAppContext) -> Vec<String> {
setup(cx);
cx.update(|cx| Theme::update(cx, |theme| theme.reduced_motion = true));
let (view, cx) = cx.add_window_view(|_, _| Long {
chosen: "r25".into(),
let (view, cx) = cx.add_window_view(|window, cx| Long {
kind,
field: cx.new(|cx| TextInput::new(window, cx)),
picks: Vec::new(),
});
cx.update(|window, _| window.activate_window());
let (trigger, list) = cx.update(|window, cx| {
let theme = cx.theme();
(
@@ -139,8 +160,26 @@ fn a_long_list_opens_with_its_choice_in_view(cx: &mut TestAppContext) {
cx.simulate_mouse_move(foot, None, Modifiers::none());
cx.simulate_click(foot, Modifiers::none());
frames(cx);
let picks = view.read_with(cx, |view, _| view.picks.clone());
assert_eq!(picks, ["r25"], "the list opens with its choice at the foot");
view.read_with(cx, |view, _| view.picks.clone())
}
#[gpui::test]
fn a_long_select_opens_with_its_choice_in_view(cx: &mut TestAppContext) {
assert_eq!(press_the_foot(Kind::Select, cx), ["r25"]);
}
#[gpui::test]
fn a_long_combobox_opens_with_its_choice_in_view(cx: &mut TestAppContext) {
assert_eq!(press_the_foot(Kind::Combobox, cx), ["r25"]);
}
#[gpui::test]
fn a_long_multi_select_opens_with_its_first_choice_in_view(cx: &mut TestAppContext) {
assert_eq!(
press_the_foot(Kind::Multi, cx),
[""],
"the press unticks r25"
);
}
/// Frames 2ms apart, past reduced motion's 1ms entrances.