Don't show extra row in toolbar if it is empty (#17888)

Closes #17851

Release Notes:

- Removed an extra row in the toolbar if it was empty.
This commit is contained in:
Zhang 2024-09-17 00:00:49 +08:00 committed by GitHub
parent fb79346e6f
commit 90b77e125a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -104,37 +104,39 @@ impl Render for Toolbar {
.border_b_1()
.border_color(cx.theme().colors().border_variant)
.bg(cx.theme().colors().toolbar_background)
.child(
h_flex()
.min_h(rems_from_px(24.))
.justify_between()
.gap(Spacing::Large.rems(cx))
.when(has_left_items, |this| {
this.child(
h_flex()
.flex_auto()
.justify_start()
.overflow_x_hidden()
.children(self.left_items().map(|item| item.to_any())),
)
})
.when(has_right_items, |this| {
this.child(
h_flex()
.map(|el| {
if has_left_items {
// We're using `flex_none` here to prevent some flickering that can occur when the
// size of the left items container changes.
el.flex_none()
} else {
el.flex_auto()
}
})
.justify_end()
.children(self.right_items().map(|item| item.to_any())),
)
}),
)
.when(has_left_items || has_right_items, |this| {
this.child(
h_flex()
.min_h(rems_from_px(24.))
.justify_between()
.gap(Spacing::Large.rems(cx))
.when(has_left_items, |this| {
this.child(
h_flex()
.flex_auto()
.justify_start()
.overflow_x_hidden()
.children(self.left_items().map(|item| item.to_any())),
)
})
.when(has_right_items, |this| {
this.child(
h_flex()
.map(|el| {
if has_left_items {
// We're using `flex_none` here to prevent some flickering that can occur when the
// size of the left items container changes.
el.flex_none()
} else {
el.flex_auto()
}
})
.justify_end()
.children(self.right_items().map(|item| item.to_any())),
)
}),
)
})
.children(secondary_item)
}
}