public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 3/3] ui: pve tree: prevent from pushing unnecessary route
Date: Mon, 15 Dec 2025 16:18:03 +0100	[thread overview]
Message-ID: <20251215151857.3420519-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20251215151857.3420519-1-d.csapak@proxmox.com>

In the tree, a route is pushed when the data table selection changes.
When the route changes externally (e.g. the browser back button), we
manually select the correct entry afterwards, which triggers a selection
change, which currently triggers another route push of the same route
that's already active.

This means that on back button click, there will be always a new route
pushed to the same path the user is already on.

Prevent that by comparing the path we want to push with what we're
currently on, and only push it when they differ.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/pve/tree.rs | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ui/src/pve/tree.rs b/ui/src/pve/tree.rs
index a496f930..bd60ecc5 100644
--- a/ui/src/pve/tree.rs
+++ b/ui/src/pve/tree.rs
@@ -389,7 +389,14 @@ impl LoadableComponent for PveTreeComp {
 
                 if let Some(node) = root.find_node_by_key(&key) {
                     let record = node.record().clone();
-                    ctx.link().push_relative_route(&record.get_path());
+                    if let Some(nav) = ctx.link().nav_context() {
+                        let new_path = record.get_path();
+                        let current_path = nav.path();
+                        if current_path != new_path {
+                            ctx.link().push_relative_route(&new_path);
+                        }
+                    }
+
                     ctx.props().on_select.emit(record);
                 }
             }
-- 
2.47.3



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


  parent reply	other threads:[~2025-12-15 15:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 15:18 [pdm-devel] [PATCH datacenter-manager 0/3] ui: pve: improve route navigation Dominik Csapak
2025-12-15 15:18 ` [pdm-devel] [PATCH datacenter-manager 1/3] ui: pve remote panels: enable router function Dominik Csapak
2025-12-15 15:18 ` [pdm-devel] [PATCH datacenter-manager 2/3] ui: pve: properly name route for 'datacenter' node Dominik Csapak
2025-12-15 15:18 ` Dominik Csapak [this message]
2025-12-16  9:14 ` [pdm-devel] applied: [PATCH datacenter-manager 0/3] ui: pve: improve route navigation 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=20251215151857.3420519-4-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-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