Skip to content

Backoffice: Pre-expand tree to target entity when opening Duplicate and Move To modals (closes #22015)#23063

Open
madsrasmussen wants to merge 14 commits into
v17/devfrom
v17/bugfix/move-duplicate-to-expand-to-source
Open

Backoffice: Pre-expand tree to target entity when opening Duplicate and Move To modals (closes #22015)#23063
madsrasmussen wants to merge 14 commits into
v17/devfrom
v17/bugfix/move-duplicate-to-expand-to-source

Conversation

@madsrasmussen
Copy link
Copy Markdown
Member

@madsrasmussen madsrasmussen commented Jun 4, 2026

Description

Fixes #22015

When opening the Duplicate To or Move To modal from a document or other tree entity, the tree is now pre-expanded to reveal the item's current location in the hierarchy. Previously, the tree always opened collapsed at the root.

@madsrasmussen madsrasmussen changed the title V17/bugfix/move duplicate to expand to source Backoffice: Pre-expand tree to target entity when opening Duplicate and Move To modals Jun 4, 2026
@madsrasmussen madsrasmussen changed the title Backoffice: Pre-expand tree to target entity when opening Duplicate and Move To modals Backoffice: Pre-expand tree to target entity when opening Duplicate and Move To modals (closes #22015) Jun 4, 2026
@madsrasmussen madsrasmussen marked this pull request as ready for review June 4, 2026 12:32
Copilot AI review requested due to automatic review settings June 4, 2026 12:32
@claude
Copy link
Copy Markdown

claude Bot commented Jun 4, 2026

Claude finished @madsrasmussen's task in 8m 2s —— View job


PR Review

Target: origin/v17/dev · Based on commit: 343eeac7 · Reviewable files: 9

Adds tree pre-expansion to Duplicate To and Move To modals: ancestors are fetched before the modal opens, passed through the modal data token, and applied to the embedded tree via the existing expansion prop. Users now land with their current location already revealed in the picker hierarchy.

  • Modified public API: UmbTreePickerModalData (exported via packages/core/tree/index.ts) — added optional treeExpansion?: UmbEntityExpansionModel
  • Affected implementations (outside this PR): None — additive optional property, all existing consumers unaffected
  • Breaking changes: None detected

Suggestions

  • duplicate-to-modal.element.ts:16 and duplicate-document-modal.element.ts:27: _treeExpansion is derived solely from this.data?.treeExpansion and is set exactly once per modal open. The @state + updated() pattern causes a redundant re-render. A computed getter removes the overhead and is simpler:
    private get _treeExpansion(): UmbEntityExpansionModel {
        return this.data?.treeExpansion ?? [];
    }
    (Inline comment posted on duplicate-to-modal.element.ts)

Approved with Suggestions for improvement

Clean, well-structured implementation. Error handling in #requestAncestors is correct — failures fall back gracefully to an unexpanded tree. The parallel Promise.all in duplicate-document.action.ts is a nice touch. Please consider the getter simplification before merging.

Labels applied: area/frontend, category/ux, category/ui

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the backoffice “Duplicate to…” and “Move to…” flows by pre-expanding the destination tree to the current entity’s location (using ancestor lookups), rather than always opening collapsed at the root.

Changes:

  • Fetch ancestor chains for the current entity and pass them to modals as an expansion model.
  • Add optional treeExpansion/expansion wiring so tree-based modals can open with a predefined expansion state.
  • Apply the same pre-expansion behavior to both the generic tree actions (duplicate/move) and the document-specific duplicate modal.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-actions/duplicate/modal/duplicate-document-modal.token.ts Extends duplicate-document modal data with optional tree expansion state.
src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-actions/duplicate/modal/duplicate-document-modal.element.ts Passes expansion state into the document duplicate destination tree.
src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-actions/duplicate/duplicate-document.action.ts Requests ancestors and supplies linked expansion entries to the document duplicate modal.
src/Umbraco.Web.UI.Client/src/packages/core/tree/tree-picker-modal/types.ts Adds treeExpansion to the generic tree picker modal data contract.
src/Umbraco.Web.UI.Client/src/packages/core/tree/tree-picker-modal/tree-picker-modal.element.ts Applies provided treeExpansion into the picker context’s expansion manager.
src/Umbraco.Web.UI.Client/src/packages/core/tree/entity-actions/move/move-to.action.ts Computes and passes treeExpansion to the tree picker modal for Move To actions.
src/Umbraco.Web.UI.Client/src/packages/core/tree/entity-actions/duplicate-to/modal/duplicate-to-modal.token.ts Extends duplicate-to modal data with optional tree expansion state.
src/Umbraco.Web.UI.Client/src/packages/core/tree/entity-actions/duplicate-to/modal/duplicate-to-modal.element.ts Passes expansion state into the duplicate-to destination tree.
src/Umbraco.Web.UI.Client/src/packages/core/tree/entity-actions/duplicate-to/duplicate-to.action.ts Computes and passes treeExpansion when opening the duplicate-to modal.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

@claude claude Bot added the category/ui User interface label Jun 4, 2026
Copy link
Copy Markdown
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works nicely in testing @madsrasmussen - I can see the expected result for all three entity actions. I just had one comment about whether you could de-duplicate some repeated code.

this.#reloadMenu();
}

async #requestAncestors() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is repeated in duplicate-to.action.ts and duplicate-document.action.ts. Worth extracting into a common helper? The try/catch, comments and removal of self all might be worth having in one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/frontend category/ui User interface category/ux User experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants