Browse Source

ensure all nodes have a intialized layout

Evan Almloff 3 years ago
parent
commit
e1120bb644
1 changed files with 6 additions and 2 deletions
  1. 6 2
      packages/tui/src/layout.rs

+ 6 - 2
packages/tui/src/layout.rs

@@ -36,9 +36,11 @@ pub(crate) struct StretchLayout {
 impl ChildDepState for StretchLayout {
     type Ctx = Rc<RefCell<Stretch>>;
     type DepState = Self;
-    // todo: update mask
+    // use tag to force this to be called when a node is built
     const NODE_MASK: NodeMask =
-        NodeMask::new_with_attrs(AttributeMask::Static(SORTED_LAYOUT_ATTRS)).with_text();
+        NodeMask::new_with_attrs(AttributeMask::Static(SORTED_LAYOUT_ATTRS))
+            .with_text()
+            .with_tag();
 
     /// Setup the layout
     fn reduce<'a>(
@@ -73,6 +75,7 @@ impl ChildDepState for StretchLayout {
             } else {
                 self.node =
                     PossiblyUninitalized::Initialized(stretch.new_node(style, &[]).unwrap());
+                changed = true;
             }
         } else {
             // gather up all the styles from the attribute list
@@ -104,6 +107,7 @@ impl ChildDepState for StretchLayout {
                 self.node = PossiblyUninitalized::Initialized(
                     stretch.new_node(style, &child_layout).unwrap(),
                 );
+                changed = true;
             }
         }
         if self.style != style {