Problem/Motivation

When you remove all configurable plugins (ie. Heading, Source, Language) from the toolbar, the "CKEditor5 plugin settings" vertical tabs section (#plugin-settings-wrapper) disappears completely from the form. This makes sense as there are no settings to configure.

Now, when you place the Heading, Source or Language plugin back on the toolbar, the plugin settings remain hidden. I think this happens because the AJAX command tries to update the no-longer-existing #plugin-settings-wrapper element.

Steps to reproduce

  • Enable CKEditor5 module.
  • Create a new text format (/admin/config/content/formats/add).
  • Choose CKEditor 5 as Text Editor.
  • Remove all configurable buttons (ie. having a corresponding vertical tab under "CKEditor5 plugin settings") from the toolbar. For a new format, this is only the "Heading" plugin.
  • Verify that the "CKEditor5 plugin settings" vertical tabs disappear from the form.
  • Drag the "Heading" button back onto the toolbar.
  • Notice how "CKEditor5 plugin settings" does not reappear. This is the bug.

Proposed resolution

T.b.d.

Remaining tasks

- Write a failing test
- Fix the bug and the test

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

Not needed

Issue fork drupal-3259443

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcvangend created an issue. See original summary.

marcvangend’s picture

Issue summary: View changes
Wim Leers’s picture

Title: Plugin settings do not appear when a configurable plugin is added » Plugin settings do not appear when a configurable plugin is added AFTER removing all

This does not happen when adding buttons with configuration for the first time — if it did, our tests would be failing. So clarified the issue title for that 🤓

Great catch though! 👍

marcvangend’s picture

Status: Active » Needs review

I must say it isn't the most elegant fix. It works but I will not be offended if someone comes up with a better solution ;-)

Abhijith S’s picture

Applied MR 1693 and it fixes the issue.

Before patch:
before

After patch:
after

RTBC +1

Wim Leers’s picture

Assigned: Unassigned » bnjmnm

@bnjmnm knows this code best, I think it'd be great if he could review it :)

lauriii’s picture

Assigned: bnjmnm » Unassigned

Getting review on this from @bnjmnm would be great, but I'm unassigning this to not discourage others from reviewing this.

Wim Leers’s picture

Title: Plugin settings do not appear when a configurable plugin is added AFTER removing all » Plugin settings do not appear when a configurable plugin is added AFTER removing all buttons
Wim Leers’s picture

I think this should be a stable blocker; no intermediate state should cause this problem. This is different from #3259892: Removing all buttons from the toolbar should not be considered an error, where we're trying to save a CKEditor 5 configuration with a state that arguably makes no sense.

bnjmnm made their first commit to this issue’s fork.

bnjmnm’s picture

This is looking good! Adding a test-only patch so there's objective confirmation the test targets this bug.

bnjmnm’s picture

didn't format the drupalci.yml edit properly in #12

Status: Needs review » Needs work

The last submitted patch, 13: 3259443-13-test-only.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Reviewed & tested by the community

The test only patch in #13 demonstrates the test is doing it's job, as is the fix!

The solution is straightforward - create an empty #plugin-settings-wrapper div if $form['editor']['settings']['subform']['plugin_settings'] doesn't exist, so it is always available to the AJAX callbacks expecting it.

Wim Leers’s picture

Yay, thanks @bnjmnm! 🚢

And thank you especially, @marcvangend!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 3259443-13-test-only.patch, failed testing. View results

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community

The merge request is RTBC, not the patch.

  • lauriii committed 7a1c45f on 10.0.x
    Issue #3259443 by marcvangend, bnjmnm, Abhijith S: Plugin settings do...

  • lauriii committed 15011eb on 9.4.x
    Issue #3259443 by marcvangend, bnjmnm, Abhijith S: Plugin settings do...

  • lauriii committed 6f5a6ea on 9.3.x
    Issue #3259443 by marcvangend, bnjmnm, Abhijith S: Plugin settings do...
lauriii’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 7a1c45f and pushed to 10.0.x. Also cherry-picked to 9.4.x and 9.3.x because CKEditor 5 is experimental. Thanks!

Status: Fixed » Closed (fixed)

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