public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH yew-widget-toolkit] form: fix dirty check when validator normalizes field values
Date: Mon, 10 Nov 2025 17:18:30 +0100	[thread overview]
Message-ID: <20251110161831.261526-1-h.laimer@proxmox.com> (raw)

Having a default value for a field that was not be present in the initial
data led to the form being marked as dirty immediatly.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 src/widget/form/context.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/widget/form/context.rs b/src/widget/form/context.rs
index e0cad70..1398847 100644
--- a/src/widget/form/context.rs
+++ b/src/widget/form/context.rs
@@ -461,6 +461,11 @@ impl FormContextState {
 
         if !radio_group {
             field.apply_value(value);
+            // update default to match the validated result, so dirty checking works correctly
+            // when the validator normalizes the value
+            if let Ok(submit_value) = &field.result {
+                field.default = submit_value.clone();
+            }
         }
 
         let slab_key;
-- 
2.47.3



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


                 reply	other threads:[~2025-11-10 16:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251110161831.261526-1-h.laimer@proxmox.com \
    --to=h.laimer@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal