Skip to content

Sort available composition folders #19373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lauraneto
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes #19327

Description

The API returns the list of available compositions for a certain content type, ordered alphabetically, but individually (not grouped by folder). The grouping is done in the FE, by doing a distinct on the folder "path", and then getting all the compositions relating to that path.
As such, the folders were ordered by the placement in which they first appeared in the non-grouped results, which was not relevant.
As a fix, I added a .sort() to the folders.
This element is shared by content types, media types and member types.

Testing

  1. Create a structure of document types and folders (not ordered alphabetically).
    Example:
    image
  2. Create a new document type and open the Compositions modal

Before the fix
image

After the fix
image

@Copilot Copilot AI review requested due to automatic review settings May 20, 2025 11:59
Copy link
Contributor

@Copilot 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 ensures that composition folders in the picker modal are displayed in alphabetical order rather than the order in which they first appear in the API response.

  • Added a .sort() call to the list of unique folder paths.
  • Updated UmbCompositionPickerModalElement to sort folder entries before mapping.

@lauraneto lauraneto requested a review from Copilot May 20, 2025 12:36
Copy link
Contributor

@Copilot 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 ensures composition folders in the picker modal are displayed in alphabetical order by grouping and then sorting folder paths.

  • Replaced manual Set-based grouping with Object.groupBy
  • Sorted folder path keys using localeCompare
  • Updated mapping to produce _compatibleCompositions from sorted groups
Comments suppressed due to low confidence (1)

src/Umbraco.Web.UI.Client/src/packages/content/content-type/modals/composition-picker/composition-picker-modal.element.ts:119

  • [nitpick] The parameter name key is generic; consider renaming it to path for clarity, e.g., .map(path => ({ path, compositions: grouped[path] })).
.map((key) => ({ path: key, compositions: grouped[key] }));

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.

Compositions ordering is confusing and difficult to use
1 participant