* [yew-devel] [PATCH yew-widget-toolkit] TabPanel/SelectionView: add an option to force rendering all tabs/views
@ 2025-06-26 12:48 Shannon Sterz
2025-06-30 11:00 ` [yew-devel] applied: " Dietmar Maurer
0 siblings, 1 reply; 2+ messages in thread
From: Shannon Sterz @ 2025-06-26 12:48 UTC (permalink / raw)
To: yew-devel
this is useful when these components contain fields that should be
registered in a `FormContext` via a `Form`. as all fields need to be
properly rendered for registration.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
src/widget/selection_view.rs | 18 +++++++++++++++++-
src/widget/tab/tab_panel.rs | 18 +++++++++++++++++-
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/widget/selection_view.rs b/src/widget/selection_view.rs
index 8ba17706..5f3ba549 100644
--- a/src/widget/selection_view.rs
+++ b/src/widget/selection_view.rs
@@ -71,6 +71,16 @@ pub struct SelectionView {
#[prop_or_default]
#[builder]
pub page_cache: bool,
+
+ /// Whether the views should be rendered dynamically or should be rendered all at once.
+ /// All rendered views that are not currently selected will be hidden via the `display: none`
+ /// CSS property.
+ ///
+ /// This is useful when using a SelectionView in a [`crate::widget::form::Form`] as all fields
+ /// in all views need to be rendered for proper registration.
+ #[prop_or_default]
+ #[builder]
+ pub force_render_all: bool,
}
impl Default for SelectionView {
@@ -136,9 +146,15 @@ impl Component for PwtSelectionView {
.context(ctx.link().callback(Msg::VisibilityChanged))
.unzip();
+ let mut render_set = IndexSet::new();
+
+ if props.force_render_all {
+ render_set.extend(props.builders.keys().cloned());
+ }
+
Self {
active: None,
- render_set: IndexSet::new(),
+ render_set,
_selection_observer,
visibility: visibility.unwrap_or_default(),
_visibility_handle,
diff --git a/src/widget/tab/tab_panel.rs b/src/widget/tab/tab_panel.rs
index aa06d585..6b72c70d 100644
--- a/src/widget/tab/tab_panel.rs
+++ b/src/widget/tab/tab_panel.rs
@@ -84,6 +84,16 @@ pub struct TabPanel {
#[prop_or_default]
#[builder]
pub tab_bar_style: TabBarStyle,
+
+ /// Whether the tabs should be rendered dynamically or should be rendered all at once.
+ /// All rendered tabs that are not currently selected will be hidden via the `display: none`
+ /// CSS property.
+ ///
+ /// This is useful when using a TabPanel in a [`crate::widget::form::Form`] as all fields
+ /// in all tabs need to be rendered for proper registration.
+ #[prop_or_default]
+ #[builder]
+ pub force_render_all: bool,
}
impl Default for TabPanel {
@@ -240,11 +250,17 @@ impl Component for PwtTabPanel {
(None, tools)
};
+ let view = props
+ .view
+ .clone()
+ .force_render_all(props.force_render_all)
+ .selection(self.selection.clone());
+
Column::new()
.with_std_props(props.as_std_props())
.class("pwt-panel")
.with_child(html! {<div {class}>{title}{bar}{tools}</div>})
- .with_child(props.view.clone().selection(self.selection.clone()))
+ .with_child(view)
.into()
}
}
--
2.39.5
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* [yew-devel] applied: [PATCH yew-widget-toolkit] TabPanel/SelectionView: add an option to force rendering all tabs/views
2025-06-26 12:48 [yew-devel] [PATCH yew-widget-toolkit] TabPanel/SelectionView: add an option to force rendering all tabs/views Shannon Sterz
@ 2025-06-30 11:00 ` Dietmar Maurer
0 siblings, 0 replies; 2+ messages in thread
From: Dietmar Maurer @ 2025-06-30 11:00 UTC (permalink / raw)
To: Yew framework devel list at Proxmox, Shannon Sterz
applied
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-30 11:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-26 12:48 [yew-devel] [PATCH yew-widget-toolkit] TabPanel/SelectionView: add an option to force rendering all tabs/views Shannon Sterz
2025-06-30 11:00 ` [yew-devel] applied: " Dietmar Maurer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox