Problem/Motivation

The list of enabled styles seems to be pretty random and also changes, that results in unreadable diffs when risks of undoing/reverting changes as well as merge conflicts.

Proposed resolution

Sort the list of paragraph types alphabetically before saving.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

mbovan’s picture

Issue summary: View changes
Issue tags: +drupalmountaincamp

Updated the issue summary and tagged it for Drupal Mountain Camp.

mbovan’s picture

Issue summary: View changes

Updated the proposed resolution.

mbovan’s picture

Assigned: Unassigned » mbovan

Assigned to myself for Drupal Mountain Camp demo.

mbovan’s picture

Assigned: mbovan » Unassigned
Status: Active » Needs review
FileSize
646 bytes

Sorted the list of styles.

Berdir’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
+++ b/src/Form/StylesOverviewForm.php
@@ -193,6 +193,7 @@ class StylesOverviewForm extends ConfigFormBase {
     parent::submitForm($form, $form_state);
     $enabled_styles = array_keys(array_filter((array) $form_state->getValue('styles'), function ($value) { return !empty($value['enabled']); }));
+    sort($enabled_styles);
     $this->config->set('enabled_styles', $enabled_styles);
     $this->config->save();

Looks good, now we just need a test.

mbovan’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
1.59 KB
985 bytes

Adding a test as well.

I couldn't easily provide a failing test-only patch...

Berdir’s picture

Status: Needs review » Fixed

Not sure if the test is really testing this, I think we'd likely need to manually change the order and then checking that resaving the form updates it.

The fancy option would be a config save event subscriber that reorders there, then it would always happen, but seems a bit overkill. This is good enough for me.

  • Berdir committed 279ae6c on 8.x-1.x authored by mbovan
    Issue #3034897 by mbovan: Sort list of enabled styles in...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.