Generative: a picture with nothing to open takes no focus
A done result tracks its focus only beside its press, so a grid with no open handler leaves focus where it was. A decided comparison drops its empty verdict row, so no gap is left under the sides.
This commit is contained in:
1 parent
81d8d52a09
commit
03e36ab0ef
4 files changed
+46
-13
No files matched your search
@@ -293,3 +293,4 @@ Per-component lines live in `tasks/`. Tags there:
|
|||||||
| T24f | 2 | PASS | |
|
| T24f | 2 | PASS | |
|
||||||
| T25a | 1 | FAIL | Cmd-Enter generated only while a text field held focus; the form set no key context of its own |
|
| T25a | 1 | FAIL | Cmd-Enter generated only while a text field held focus; the form set no key context of its own |
|
||||||
| T25a | 2 | PASS | |
|
| T25a | 2 | PASS | |
|
||||||
|
| T25b | 1 | FAIL | a done result with nothing to open still took focus on a press and drew a ring the keys could not reach |
|
||||||
+12
-10
@@ -173,16 +173,18 @@ impl RenderOnce for ABCompareView {
|
|||||||
.flex_col()
|
.flex_col()
|
||||||
.gap_3()
|
.gap_3()
|
||||||
.child(div().w_full().flex().flex_wrap().gap_3().children(sides))
|
.child(div().w_full().flex().flex_wrap().gap_3().children(sides))
|
||||||
.child(
|
.when(!verdicts.is_empty(), |column| {
|
||||||
div()
|
column.child(
|
||||||
.flex()
|
div()
|
||||||
.flex_wrap()
|
.flex()
|
||||||
.items_center()
|
.flex_wrap()
|
||||||
.gap_2()
|
.items_center()
|
||||||
.text_size(theme.text_size(TextSize::Sm))
|
.gap_2()
|
||||||
.text_color(colors.fg_muted)
|
.text_size(theme.text_size(TextSize::Sm))
|
||||||
.children(verdicts),
|
.text_color(colors.fg_muted)
|
||||||
)
|
.children(verdicts),
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,9 +128,9 @@ impl RenderOnce for GenerationGrid {
|
|||||||
Outcome::Done(picture) => {
|
Outcome::Done(picture) => {
|
||||||
let open = self.on_open.clone();
|
let open = self.on_open.clone();
|
||||||
frame
|
frame
|
||||||
.track_focus(&focus)
|
|
||||||
.when_some(open, |tile, open| {
|
.when_some(open, |tile, open| {
|
||||||
tile.cursor_pointer()
|
tile.track_focus(&focus)
|
||||||
|
.cursor_pointer()
|
||||||
.on_mouse_down(MouseButton::Left, |_, window, _| {
|
.on_mouse_down(MouseButton::Left, |_, window, _| {
|
||||||
window.prevent_default()
|
window.prevent_default()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
use std::{cell::RefCell, rc::Rc, time::Duration};
|
use std::{cell::RefCell, rc::Rc, time::Duration};
|
||||||
|
|
||||||
use gpui::{Context, IntoElement, ParentElement, Render, Styled, TestAppContext, Window, div, px};
|
use gpui::{
|
||||||
|
Context, IntoElement, Modifiers, ParentElement, Render, Styled, TestAppContext, Window, div,
|
||||||
|
point, px,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{press, settle, setup, tab};
|
use super::{press, settle, setup, tab};
|
||||||
use crate::generative::{
|
use crate::generative::{
|
||||||
@@ -94,6 +97,33 @@ fn only_done_results_open_and_a_failure_retries(cx: &mut TestAppContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A single picture with nothing to open it.
|
||||||
|
struct Still;
|
||||||
|
|
||||||
|
impl Render for Still {
|
||||||
|
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||||
|
div().w(px(420.0)).child(GenerationGrid::new(
|
||||||
|
"still",
|
||||||
|
[Outcome::Done("missing.jpg".into())],
|
||||||
|
1.5,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
fn a_picture_with_nothing_to_open_takes_no_focus(cx: &mut TestAppContext) {
|
||||||
|
setup(cx);
|
||||||
|
let (_, cx) = cx.add_window_view(|_, _| Still);
|
||||||
|
cx.update(|window, _| window.activate_window());
|
||||||
|
settle(cx);
|
||||||
|
cx.simulate_click(point(px(100.0), px(60.0)), Modifiers::none());
|
||||||
|
settle(cx);
|
||||||
|
assert!(
|
||||||
|
cx.update(|window, cx| window.focused(cx).is_none()),
|
||||||
|
"no ring on a picture the keys cannot use"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Three variations with the first chosen, and what it heard.
|
/// Three variations with the first chosen, and what it heard.
|
||||||
struct Variations(Heard);
|
struct Variations(Heard);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user