Skip to content

Commit

Permalink
ui: Don't break flex layout when using WithRemSize (#12076)
Browse files Browse the repository at this point in the history
This PR fixes an issue where the flex hierarchy wasn't getting broken by
the use of `WithRemSize`.

Release Notes:

- N/A
  • Loading branch information
maxdeviant committed May 21, 2024
1 parent 315e45f commit 2f31026
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/ui/src/components/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl Render for ContextMenu {
let ui_font_size = ThemeSettings::get_global(cx).ui_font_size;

div().occlude().elevation_2(cx).flex().flex_row().child(
WithRemSize::new(ui_font_size).child(
WithRemSize::new(ui_font_size).flex().child(
v_flex()
.min_w(px(200.))
.track_focus(&self.focus_handle)
Expand Down
8 changes: 7 additions & 1 deletion crates/ui/src/with_rem_size.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gpui::{
div, AnyElement, Bounds, Div, DivFrameState, Element, ElementId, GlobalElementId, Hitbox,
IntoElement, LayoutId, ParentElement, Pixels, WindowContext,
IntoElement, LayoutId, ParentElement, Pixels, StyleRefinement, Styled, WindowContext,
};

/// An element that sets a particular rem size for its children.
Expand All @@ -18,6 +18,12 @@ impl WithRemSize {
}
}

impl Styled for WithRemSize {
fn style(&mut self) -> &mut StyleRefinement {
self.div.style()
}
}

impl ParentElement for WithRemSize {
fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
self.div.extend(elements)
Expand Down

0 comments on commit 2f31026

Please sign in to comment.