Sort paragraph names alphabetically in node add/edit form

Created on 20 July 2016, over 8 years ago
Updated 16 August 2023, over 1 year ago

Is it possible to sort paragraph adding list alphabetically based on Paragraph name (not machine name if thats what is currently used)?

See the attached image, for what is happening currently.

I expected the following order on the dropdown:

  • 1 Column
  • 2 Column
  • 3 Column
  • Accordion
  • Block
  • Call to action
  • Customer Testimonial
  • Featured Content
  • Header Image
  • Image Left Text Right
  • Image Right Text Left
๐Ÿ’ฌ Support request
Status

Fixed

Version

1.0

Component

User interface

Created by

๐Ÿ‡ฆ๐Ÿ‡บAustralia realityloop

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States webdrips

    For me, the dropdown list wasn't even sorting by the weights set, and I had to set my custom module weight to 12 (one higher than paragraphs) to get the following code working:

    ...
    switch ($form_id) {
      case 'blah':
        $field = 'field_blah';
        break;
    ...
    }
    
    if (isset($form[$field]['widget']['add_more']['add_more_select']['#options'])) {
      natsort($form[$field]['widget']['add_more']['add_more_select']['#options']);
    }
    ...
    
  • I want to fix the same issue.
    Why is this issue marked as "fixed" ?
    There is no patch.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada JayDarnell Guelph, Ontario

    This issue needs to be reopened.

  • who is closing unresolved issues, especially lying by marking it as "fixed" ?

  • First commit to issue fork.
  • You can also find your field config for the paragraph field and manually sort the paragraph names in the field target_bundles setting.

    settings:
      handler: 'default:paragraph'
      handler_settings:
        target_bundles:
          accordion_section: accordion_section
          anchor: anchor
          article_listing: article_listing
          background_section_break: background_section_break
          buttons: buttons
          card_gallery: card_gallery
          card_grid: card_grid
          collection: collection
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mlncn Minneapolis, MN, USA

    It's fair for the maintainers to say the support request here is fixed, but i agree there should be a feature request opened to make it easy to alphabetize paragraph types.

    If you go to any taxonomy administration page for any vocabulary (for example /admin/structure/taxonomy/manage/example/overview ) it will have a re-orderable list of terms, and there is also a "Reset to alphabetical" button at the bottom.

    Paragraph configuration pages should have the same option, probably.

    (That button goes to a confirmation form, which ultimately invokes this resetWeights() method, which actually simply removes the weightsโ€” with the presumption that terms everywhere will be ordered first by weight ascending, and then alphabetically by label, so that when they are all zero the alphabetical order is used by default. That would be a great model for Paragraphs to follow with paragraph types, if possible. But againโ€” a new issue should be created.)

Production build 0.71.5 2024