From: Shannon Sterz <s.sterz@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH yew-widget-toolkit] TabPanel/SelectionView: add an option to force rendering all tabs/views
Date: Thu, 26 Jun 2025 14:48:05 +0200 [thread overview]
Message-ID: <20250626124805.317672-1-s.sterz@proxmox.com> (raw)
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
next reply other threads:[~2025-06-26 12:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 12:48 Shannon Sterz [this message]
2025-06-30 11:00 ` [yew-devel] applied: " Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250626124805.317672-1-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=yew-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox