feat: apply declarative render rule across components

This commit is contained in:
2026-11-10 08:04:24 +07:00
parent fbc4f24d16
commit 44abaf47a9
12 changed files with 545 additions and 561 deletions
+28 -30
View File
@@ -366,7 +366,15 @@ impl RenderOnce for DropdownMenu {
trigger
};
let mut wrapper = div()
let items = if self.open {
self.items
.map(|build| Rc::from(build(window, cx)))
.unwrap_or_else(|| Rc::from([]))
} else {
Rc::from([])
};
div()
.relative()
.child(
canvas(
@@ -421,34 +429,24 @@ impl RenderOnce for DropdownMenu {
.absolute()
.inset_0(),
)
.child(trigger);
let items = if self.open {
self.items
.map(|build| Rc::from(build(window, cx)))
.unwrap_or_else(|| Rc::from([]))
} else {
Rc::from([])
};
if let Some(panel) = anchored_menu_panel(
window,
cx,
&self.id,
self.open,
items,
None,
*keyboard_open.read(cx),
Some(on_open),
label,
None,
&trigger_bounds,
&panel_chrome,
enter_duration,
) {
wrapper = wrapper.child(panel);
}
wrapper
.child(trigger)
.when_some(
anchored_menu_panel(
window,
cx,
&self.id,
self.open,
items,
None,
*keyboard_open.read(cx),
Some(on_open),
label,
None,
&trigger_bounds,
&panel_chrome,
enter_duration,
),
|wrapper, panel| wrapper.child(panel),
)
}
}