form: Fix label text wrapping issue (#1034)

| Before | After |
| - | - |
| <img width="752" alt="image"
src="https://github.com/user-attachments/assets/32abd11a-39c6-4045-9727-3188c46e482c"
/> | <img width="752" alt="image"
src="https://github.com/user-attachments/assets/98e45484-1c05-4d90-977f-efd9b89d9dd9"
/> |
This commit is contained in:
Floyd Wang 2025-07-03 15:09:57 +08:00 committed by GitHub
parent 51f36e1256
commit f4025a9447
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View file

@ -183,7 +183,7 @@ impl Render for FormStory {
)
.child(
form_field()
.label("Birthday")
.label("Please select your birthday")
.child(DatePicker::new(&self.date))
.description("Select your birthday, we will send you a gift."),
)

View file

@ -378,14 +378,18 @@ impl RenderOnce for FormField {
.items_center()
.when_some(self.label, |this, builder| {
this.child(
h_flex().gap_1().child(builder.render(window, cx)).when(
self.required,
|this| {
h_flex()
.gap_1()
.child(
div()
.overflow_x_hidden()
.child(builder.render(window, cx)),
)
.when(self.required, |this| {
this.child(
div().text_color(cx.theme().danger).child("*"),
)
},
),
}),
)
}),
)