Bundle list on "Add entity" pages (such as /node/add, /media/add) can have different bundle order than the bundle list on the bundle administration pages (such as /admin/structure/types, /admin/structure/media) because the former is not sorted while the latter is sorted alphabetically (and by weight if possible).

I suggest to sort bundle list on "Add entity" pages.

Comments

maximpodorov created an issue. See original summary.

maximpodorov’s picture

Status: Active » Needs review
StatusFileSize
new1.45 KB
kristen pol’s picture

Here's what it looks like without the patch.

kristen pol’s picture

And after the patch.

jyotimishra-developer’s picture

Hi, I have tested this patch with Drupal 9.0 as well as 8.9.x version since i was facing same order issue in 8.9.x version of Drupal.
patch in #2 is working fine in both versions. sharing screenshots for reference in before and after patch manner.

kristen pol’s picture

@jyotimishra123 Thanks but why did you test it when it had already been tested?

jyotimishra-developer’s picture

Hi @Kristen Pol, the issue was mentioning for 9.0 version and i was facing this in 8.9 too, so i found this patch and applied and shared my result too. i did not specifically test this issue, was working something and used this patch so i thought i should share the result too..
I m new to this contribution so did not know that only one can share the testing response..Thanks!!

kristen pol’s picture

@jyotimishra123 Gotcha. Welcome to Drupal contribution! Hope you're able to help out during the D9 porting weekend.

jyotimishra-developer’s picture

Status: Needs review » Reviewed & tested by the community
xjm’s picture

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Thanks @jyotimishra123! Usually we want to make sure we don't duplicate others' work because it adds noise, it's not fair in terms of issue credit, and it's better to work on things someone else hasn't already addressed. :)

That said, your manual testing results do help document why you consider the issue RTBC, which is good. We value it when someone who reviews a patch documents what they tested and why they think the issue is ready. So for that reason I'm keeping your credit on the issue as well as @Kristen Pol for the reviews.

A few more things we should address here:

  1. I think we need an automated test for this.

  2. +++ b/core/modules/node/src/Controller/NodeController.php
    @@ -104,6 +104,10 @@ public function addPage() {
    +    // Sort the entities using the entity class's sort() method.
    +    // See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
    +    uasort($content, [$this->entityTypeManager()->getDefinition('node_type')->getClass(), 'sort']);
    

    I'm confused here. If we're using the Entity API to sort it, why are we also doing a uasort() on the result?
     

  3. I'm also wondering if this should be addressed at the level of the list builder, rather than in the controllers. The fact that we have to repeat something on the node list builder makes me think the sorting should be done earlier.

jyotimishra-developer’s picture

Hi @xjm,
Hoping you fine in this pandemic situation due to coronavirus!!
Agreed with your point and also got your point.
will take care these things in future, Thanks a alot.

Version: 9.0.x-dev » 9.1.x-dev

Drupal 9.0.10 was released on December 3, 2020 and is the final full bugfix release for the Drupal 9.0.x series. Drupal 9.0.x will not receive any further development aside from security fixes. Sites should update to Drupal 9.1.0 to continue receiving regular bugfixes.

Drupal-9-only bug reports should be targeted for the 9.1.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.2.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.1.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mohit_aghera’s picture

Status: Needs work » Closed (outdated)
Issue tags: +Bug Smash Initiative

I came across this issue while doing bugsmash triage.
I am not able to reproduce this issue.

It seems that this issue is already been fixed.

I can see that sort method is added on load() https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co... for ConfigEntityListBuilder.php

NodeTypeListBuilder essentially calls `ConfigEntityListBuilder` only.

There is another issue #2265487: ConfigEntity based lists with items containing non-ascii characters are not sorted correctly which we worked on to provide sorting for non-ascii characters.
I think we should close this since above issue is more generic, also this isn't reproducible anymore.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

kuldeepbarot’s picture

StatusFileSize
new1.5 KB

Re-rolled patch from #2 for D11.4.6