Skip to content

Re-sort renamed server groups and other nodes in the Object Explorer instead of waiting for a reload. #8015 - #10586

Closed
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-8015-sort-renamed-groups
Closed

dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-8015-sort-renamed-groups

Conversation

@dpage

@dpage dpage commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Renaming a node in the Object Explorer updated its label but left it where it was, because the tree sorts on the name each item was loaded with. After an update, the node's sort name is now set to the new label and the node is moved into sorted position among its siblings. Its id-based path and any expanded children are kept, and columns keep their attribute number order.

Test plan

  • New Jest spec regression/javascript/tree/tree_resort_spec.js, run against a real TreeModelX
  • yarn jest regression/javascript/tree regression/javascript/browser: 80 passed
  • eslint on the changed files

Closes #8015

Summary by CodeRabbit

  • Bug Fixes
    • Renamed tree nodes now move to the correct sorted position, and selection can scroll to the node if it moves.

…instead of waiting for a reload. pgadmin-org#8015

Renaming a node updated its label in place, but the tree sorts on the
name each item was loaded with, so the node stayed where it was until
the tree was reloaded. After an update, the node's sort name is now set
to the new label and it is moved to its sorted position amongst its
siblings, keeping its id-based path and any expanded children. Columns
keep their attribute number order.

Closes pgadmin-org#8015
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pgadmin-org/pgadmin4/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3955a389-e948-4d24-a19a-0e3fecf04812
📥 Commits

Reviewing files that changed from the base of the PR and between 607c9ec and 5f25946.

📒 Files selected for processing: 3
  • web/pgadmin/browser/static/js/browser.js
  • web/pgadmin/static/js/tree/tree.js
  • web/regression/javascript/tree/tree_resort_spec.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

Renamed tree nodes are now resorted among siblings. The browser passes the movement result to selection. Regression tests cover sorting, expanded-node children, path preservation, unchanged positions, and column nodes.

Changes

Tree Rename Resorting

Layer / File(s) Summary
Resort behavior and regression coverage
web/pgadmin/static/js/tree/tree.js, web/regression/javascript/tree/tree_resort_spec.js
Added Tree.resortItem to update a renamed non-column node’s basename and sibling position. Tests cover sorted placement, expanded-node children, path preservation, unchanged positions, and column nodes.
Browser rename integration
web/pgadmin/browser/static/js/browser.js
After updating a node label, onUpdateTreeNode resorts the node and passes the movement result to select.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 5f259

The rename and resort change is mergeable after normal checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Linked Issues check Passed Issue #8015 identifies alphabetical sorting as an alternative to drag-and-drop and reports that renaming does not reorder a group until reload. The update handler now calls Tree.resortItem after a n…
Out of Scope Changes check Passed The changes are limited to the tree reorder method, the update-handler integration, and regression tests. Each change supports the immediate alphabetical reorder behavior for issue #8015. No unrelated…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: renamed Object Explorer nodes are re-sorted immediately without waiting for a reload.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dpage

dpage commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

The issue only mentions server groups, but this deliberately applies to every node type renamed in the Object Explorer (servers, tables and so on), so a renamed node always ends up where a reload of the tree would put it.

@dpage

dpage commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Squashed and merged as a6374d1.

dpage added a commit that referenced this pull request Oct 15, 2026
@dpage dpage closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add possibility to reorder server groups

1 participant