Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - fix upsert_leaf not setting a MeasureFunc for new leaf nodes #7351

Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions crates/bevy_ui/src/flex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use bevy_hierarchy::{Children, Parent};
use bevy_log::warn;
use bevy_math::Vec2;
use bevy_transform::components::Transform;
use bevy_utils::HashMap;
use bevy_utils::{Entry, HashMap};
use bevy_window::{PrimaryWindow, Window, WindowResolution, WindowScaleFactorChanged};
use std::fmt;
use taffy::{
Expand Down Expand Up @@ -108,14 +108,19 @@ impl FlexSurface {
size
},
));

if let Some(taffy_node) = self.entity_to_taffy.get(&entity) {
self.taffy.set_style(*taffy_node, taffy_style).unwrap();
self.taffy.set_measure(*taffy_node, Some(measure)).unwrap();
} else {
let taffy_node = taffy.new_leaf(taffy_style).unwrap();
self.entity_to_taffy.insert(entity, taffy_node);
}
let taffy_node = match self.entity_to_taffy.entry(entity) {
Entry::Occupied(entry) => {
let taffy_node = *entry.get();
self.taffy.set_style(taffy_node, taffy_style).unwrap();
taffy_node
}
Entry::Vacant(entry) => {
let taffy_node = taffy.new_leaf(taffy_style).unwrap();
entry.insert(taffy_node);
taffy_node
}
};
self.taffy.set_measure(taffy_node, Some(measure)).unwrap();
}

pub fn update_children(&mut self, entity: Entity, children: &Children) {
Expand Down