T12c, T13 review fixes: an emptied lightbox closes through its close path, keys pass over disabled and loading rows, the list cursor follows its row through a re-sort

This commit is contained in:
ZacharyZhang-NY committed 2026-09-25 21:21:33 -04:00
1 parent f8daaf282b
commit 492578a67c
8 files changed
+196 -41

No files matched your search

+10 -3
View File
@@ -81,7 +81,7 @@ pub struct Lightbox {
}
impl Lightbox {
/// Render it while open; the owner keeps `at` and moves it in `on_step`.
/// Render it while open; the owner keeps `at` and moves it in `on_step`. With no pictures left it closes, handing focus back.
pub fn new(
id: impl Into<ElementId>,
slides: impl IntoIterator<Item = Slide>,
@@ -90,7 +90,7 @@ impl Lightbox {
) -> Self {
let slides: Vec<Slide> = slides.into_iter().collect();
assert!(
at < slides.len(),
slides.is_empty() || at < slides.len(),
"slide {at} is past the last of {}",
slides.len()
);
@@ -127,6 +127,11 @@ impl RenderOnce for Lightbox {
on_close(window, cx)
})
};
if count == 0 {
log::info!("lightbox {:?}: no pictures left", self.id);
window.defer(cx, move |window, cx| close(window, cx));
return div().into_any_element();
}
let step: OnStep = {
let (id, on_step) = (self.id.clone(), self.on_step);
Rc::new(move |to, window, cx| {
@@ -276,6 +281,8 @@ impl RenderOnce for Lightbox {
),
),
);
deferred(anchored().position(Point::default()).child(stage)).with_priority(1)
deferred(anchored().position(Point::default()).child(stage))
.with_priority(1)
.into_any_element()
}
}
+20 -1
View File
@@ -33,6 +33,7 @@ struct Guides {
at: usize,
log: Vec<String>,
lower: bool,
pictures: usize,
}
fn target() -> Bounds<gpui::Pixels> {
@@ -60,7 +61,10 @@ impl Render for Guides {
cx.notify();
})
};
let slides = ["a", "b", "c"].map(|name| Slide::new(Path::new("/missing/ely.png"), name));
let slides = ["a", "b", "c"]
.into_iter()
.take(self.pictures)
.map(|name| Slide::new(Path::new("/missing/ely.png"), name));
let steps = [
TourStep::new(target(), "Here", "The first stop"),
TourStep::new(
@@ -129,6 +133,7 @@ fn guides(cx: &mut TestAppContext) -> (Entity<Guides>, &mut VisualTestContext) {
at: 0,
log: Vec::new(),
lower: false,
pictures: 3,
});
settle(cx);
(view, cx)
@@ -167,6 +172,20 @@ fn the_lightbox_steps_with_arrows_and_escape_hands_focus_back(cx: &mut TestAppCo
assert!(before_focused(&view, cx));
}
#[gpui::test]
fn a_lightbox_whose_pictures_go_away_closes_and_hands_focus_back(cx: &mut TestAppContext) {
let (view, cx) = guides(cx);
open(&view, Open::Lightbox, cx);
assert!(!before_focused(&view, cx), "the lightbox took focus");
view.update(cx, |guides, cx| {
guides.pictures = 0;
cx.notify();
});
settle(cx);
assert!(state(&view, cx).0.is_none(), "it closed");
assert!(before_focused(&view, cx), "focus went back");
}
#[gpui::test]
fn the_dark_closes_the_lightbox_and_the_picture_does_not(cx: &mut TestAppContext) {
let (view, cx) = guides(cx);