Misc · Asking and learning: Submit never rests; radio labels wrap

Survey's Submit asks for any missing answer instead of resting, so no
untick takes its focus handle out of the tree. Flashcards turn and go
round, and a quiz pick clears its ask, through methods the tests reach;
the poll's rows show which one holds the vote. forms::Radio's label
wraps in its own block, as Checkbox's does, so a long one stays in a
narrow box.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-28 03:11:52 -04:00
1 parent 86c9de7d0a
commit 46aa381eee
9 files changed
+136 -56

No files matched your search

+7 -1
View File
@@ -143,7 +143,13 @@ impl RenderOnce for Radio {
})
})
.child(radio_mark(self.on, focused, self.disabled, changes, cx))
.children(self.label)
.children(self.label.map(|label| {
div()
.debug_selector(|| "radio-label".into())
.flex_1()
.min_w_0()
.child(label)
}))
}
}
-21
View File
@@ -475,24 +475,3 @@ fn a_long_choice_keeps_its_list_inside_the_window(cx: &mut TestAppContext) {
"{list:?}"
);
}
/// A checkbox whose label runs past its narrow box.
struct Worded;
impl Render for Worded {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
let label = "Projects/Atrium/Recordings/Walkthrough of the atrium at noon.mov";
div()
.w(px(200.0))
.child(Checkbox::new("worded", false).label(label))
}
}
#[gpui::test]
fn a_long_checkbox_label_wraps_inside_its_box(cx: &mut TestAppContext) {
setup(cx);
let (_, cx) = cx.add_window_view(|_, _| Worded);
cx.run_until_parked();
let label = cx.debug_bounds("checkbox-label").expect("the label draws");
assert!(label.right() <= px(200.0), "{label:?}");
}
+30 -3
View File
@@ -1,11 +1,11 @@
use gpui::{
Context, IntoElement, KeyBinding, KeyUpEvent, Keystroke, Modifiers, MouseButton, Render,
SharedString, TestAppContext, VisualTestContext, Window, point, px,
Context, IntoElement, KeyBinding, KeyUpEvent, Keystroke, Modifiers, MouseButton, ParentElement,
Render, SharedString, Styled, TestAppContext, VisualTestContext, Window, div, point, px,
};
use super::setup;
use crate::{
forms::{IconPicker, InlineEdit, SignaturePad, Stroke},
forms::{Checkbox, Choice, IconPicker, InlineEdit, RadioGroup, SignaturePad, Stroke},
primitives::{FocusNext, IconName},
};
@@ -144,3 +144,30 @@ fn an_inline_edit_takes_tab_opens_on_enter_and_takes_focus_back(cx: &mut TestApp
"focus came back after the first"
);
}
/// A checkbox and a radio whose labels run past their narrow box.
struct Worded;
impl Render for Worded {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
let label = "Projects/Atrium/Recordings/Walkthrough of the atrium at noon.mov";
div()
.w(px(200.0))
.child(Checkbox::new("worded", false).label(label))
.child(RadioGroup::new(
"worded-radios",
[Choice::new("one", label)],
))
}
}
#[gpui::test]
fn long_labels_wrap_inside_their_box(cx: &mut TestAppContext) {
setup(cx);
let (_, cx) = cx.add_window_view(|_, _| Worded);
cx.run_until_parked();
for selector in ["checkbox-label", "radio-label"] {
let label = cx.debug_bounds(selector).expect("the label draws");
assert!(label.right() <= px(200.0), "{selector}: {label:?}");
}
}