From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 01CF61FF170 for ; Thu, 26 Jun 2025 14:48:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A29C739313; Thu, 26 Jun 2025 14:49:07 +0200 (CEST) From: Shannon Sterz To: yew-devel@lists.proxmox.com Date: Thu, 26 Jun 2025 14:48:05 +0200 Message-Id: <20250626124805.317672-1-s.sterz@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.020 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [yew-devel] [PATCH yew-widget-toolkit] TabPanel/SelectionView: add an option to force rendering all tabs/views X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "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 --- 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! {
{title}{bar}{tools}
}) - .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