public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Azharul Haque <haque@azharul.com>
To: pve-devel@lists.proxmox.com
Cc: haque@azharul.com
Subject: [PATCH 2/3] fix #4281: ui: fix stale Continue button state on realm switch
Date: Mon, 10 Aug 2026 01:39:40 -0400	[thread overview]
Message-ID: <20260810053941.17000-3-haque@azharul.com> (raw)
In-Reply-To: <20260810053941.17000-1-haque@azharul.com>

Form(onChanged: ...) revalidates against whatever fields are
currently mounted at the moment a FormField's own value changes.
For the realm dropdown that runs before the following rebuild
adds/removes the username/password fields for the newly selected
realm's type, so Continue got enabled/disabled based on the
outgoing realm's field set rather than the incoming one. Most
visibly, switching from an OpenID realm to a password realm left
Continue enabled with both fields empty, only failing validation
once actually pressed.

Recompute _submitButtonEnabled explicitly in onDomainChanged instead:
OpenID realms have nothing to validate, so enable it directly; other
realms are revalidated in a post-frame callback once the rebuild has
settled. Do the same after the initial realm auto-selection in
_getAccessDomains(), in case the default realm is an OpenID one.

Signed-off-by: Azharul Haque <haque@azharul.com>
---
 lib/proxmox_login_form.dart | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/lib/proxmox_login_form.dart b/lib/proxmox_login_form.dart
index b73165c..002838c 100644
--- a/lib/proxmox_login_form.dart
+++ b/lib/proxmox_login_form.dart
@@ -396,6 +396,31 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
                                     setState(() {
                                       _selectedDomain = value;
                                     });
+                                    // The Form's onChanged callback validates
+                                    // against whatever fields are mounted at
+                                    // the moment the dropdown's own value
+                                    // changes, which runs before this rebuild
+                                    // adds/removes the username/password
+                                    // fields for the newly selected realm.
+                                    // Recompute once that rebuild has
+                                    // happened so we validate the field set
+                                    // that's actually showing.
+                                    if (value?.isOpenIdRealm == true) {
+                                      setState(() {
+                                        _submitButtonEnabled = true;
+                                      });
+                                    } else {
+                                      WidgetsBinding.instance
+                                          .addPostFrameCallback((_) {
+                                        if (!mounted) return;
+                                        setState(() {
+                                          _submitButtonEnabled = _formKey
+                                                  .currentState
+                                                  ?.validate() ??
+                                              false;
+                                        });
+                                      });
+                                    }
                                   },
                                   onOriginSubmitted: () {
                                     final isValid =
@@ -828,6 +853,9 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
     setState(() {
       _progressModel.inProgress -= 1;
       _selectedDomain = selection;
+      // An OpenID realm has no username/password to fill in, so there's
+      // nothing for the form to validate before Continue is usable.
+      _submitButtonEnabled = selection?.isOpenIdRealm == true;
     });
 
     return response;
-- 
2.50.1 (Apple Git-155)




  parent reply	other threads:[~2026-08-10 12:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10  5:39 [PATCH 0/3] ui: implement OpenID Connect login flow for #4281 Azharul Haque
2026-08-10  5:39 ` [PATCH 1/3] fix #4281: ui: add OpenID Connect login flow to login form Azharul Haque
2026-08-10  5:39 ` Azharul Haque [this message]
2026-08-10  5:39 ` [PATCH 3/3] fix #4281: ui: use a namespaced OpenID callback scheme Azharul Haque

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=20260810053941.17000-3-haque@azharul.com \
    --to=haque@azharul.com \
    --cc=pve-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