Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Following error message is preventing saving the text format configuration form:
Depends on textPartLanguage, which is not enabled.
Steps to reproduce
- Add language toolbar item to the toolbar on text format using CKE 5
- Save text format
- Return back to the form and remove language toolbar item from the toolbar
- Try to save text format, the error should now appear
Proposed resolution
Ensure this nonsensical error no longer appears, of course!
Remaining tasks
Basic fix.Test coverage>- Generalize this validation → follow-up: #3259795: Generalize textPartLanguage's validation: no configuration allowed unless the plugin's toolbar item is active.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#20 | 3248177-20-language-toolbar-item-TEST-ONLY-FAIL.patch | 3.29 KB | marcvangend |
Issue fork drupal-3248177
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:
Comments
Comment #2
lauriiiComment #3
Wim Leers😬
Comment #4
Wim LeersComment #6
marcvangendI have no idea where to start fixing this, but if someone can give me a nudge in the right direction, I'll give it a try.
Meanwhile, here's a workaround if someone wants to disable the language selector:
drush cex
).editor.editor.[format].yml
file for the input format you want to change.- textPartLanguage
under settings.toolbar.items.ckeditor5_language:
and the line withlanguage_list:
below it.drush cim
).Comment #7
marcvangendI tried to understand why this is happening. It seems that the validation (
\Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemDependencyConstraintValidator
) kicks off and sets an error before\Drupal\ckeditor5\Plugin\Editor\CKEditor5::injectPluginSettingsForm
has the chance to remove the settings form. I was not (yet) able to figure out why this happens, or why it does not happen when removing the Heading plugin (\Drupal\ckeditor5\Plugin\CKEditor5Plugin\Heading
).Comment #9
Wim LeersHi again, @marcvangend! Long time no see! 😄
#6 is accurate: that is the valid/viable work-around today.
#7:
\Drupal\Tests\ckeditor5\FunctionalJavascript\AdminUiTest
seems appropriate.→ only the
language
button has theCKEditor5ToolbarItemDependencyConstraint
constraintThat also explains why this does not happen for the
or plugins (and their respective buttons).IIRC
textPartLanguage
was the first button with required configuration. For Heading, it was added later. Source Editing was added way later.Instead of hardcoding that, I think we should update the config schema and/or validators to always trigger this validation error for any plugins that have both toolbar items (
$definition->hasToolbarItems() === TRUE
) and configuration ($definition->isConfigurable() === TRUE
).attached a patchcreated an MR that fixes the problem. We still need to fix the two points 2 and 3 though!Comment #10
Wim LeersFor point 3 in #9: we can check the https://www.drupal.org/project/ckeditor5 commit history and issues to get clarity on this if we need to, but I think #9 is sufficient for now 😊
Comment #11
marcvangendFirst manual test result: the fix works as expected.
I will come back to this later.
Comment #12
Wim LeersQuick issue summary update; will need to refine later.
Comment #13
Wim LeersThere, da579db4f0b3957fbf933ea338a8122d9950f0f7 should help you be more productive if you choose to tackle this, @marcvangend :D
Comment #14
marcvangendOK, I've been trying to get a test working, but I'm stuck at the point where I need to add the language button to the active toolbar. I have tried triggering the arrow down key event in different ways:
I have also tried dragging the button onto the active toolbar:
Tips are appreciated.
Comment #15
marcvangendComment #16
Wim LeersAwesome — thank you so much! 🙏
You can find an example in
\Drupal\Tests\ckeditor5\FunctionalJavascript\LanguageTest::test()
:→ interpretation: first wait for it, then trigger the right keyboard event, then wait for the AJAX request and response to get processed.
Once that's done, you can move on to the next operation in your test!
Comment #17
marcvangendNice, good to see that someone has already solved this problem for me :-)
Seeing this, I noticed that we already have \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5AllowedTagsTest::testLanguageConfigForm. Wouldn't it make sense to expand that test, instead of adding a new one in AdminUiTest? (Maybe we need to have a good look at the naming and organisation of all test classes in core/modules/ckeditor5/tests/src/FunctionalJavascript. It seems a bit messy and inconsistent to me, but maybe I'm just blind to the logic.)
Comment #18
Wim LeersAhhhh — yes! I didn't spot that test method, because it's in an odd location 😬 I think we should move it into
AdminUiTest
because it not testing anything related to allowed tags, despite the name of its current class!+1! There is some logic to it though:
(Image|Media|MediaLibrary)Test
each test the functionality of those CKE5 pluginsCKEditor5OffCanvasTest
tests CKE5's compatibility with Drupal core's off-canvas functionalityCKEditor5CKEditor4Compatibility
tests that CKE5 and CKE4 can execute in the same documentAdminUiTest
tests general admin UI functionalityCKEditor5AllowedTagsTest
tests the impact of admin UI interactions on the list of allowed HTML tags — I think it should be renamed toAdminUiFilterHtmlTest
or something like that — would you like to do that? 🤞LanguageTest
really tests CKE5's translation support — I think it should be renamed — would you like to do that? 🤞CKEditor5Test
is kind of a catch all which should also be scrutinized. At a minimum I think::testLanguageOfPartsPlugin()
should be moved into its own test, similar to the first bullet in this listComment #19
marcvangendSounds like a plan. I created a follow-up issue for the shuffling and renaming: #3259555: Organize and rename CKEditor 5 tests and test classes
Comment #20
marcvangendAdding the test-only patch for review.
Comment #22
marcvangendExpected test failure.
Comment #23
LendudeTest looks good, so lets remove the filtering on test groups and run the fix with the full suite.
Comment #24
marcvangendComment #25
Wim Leers3766 failures — huh! That's not possible.
All of them are like this:
I don't see why/how this can happen. I wonder if it's because it changes
drupalci.yml
? Re-testing…Comment #26
Wim LeersAh, apparently this was caused by an upstream change and it got fixed 1 minute ago: #3259744: PHPUnit 9.5.12 (released 2022-01-21) throws unhandled deprecation notice on "Drupal\Tests\Listeners\DrupalListener". 👍
The new test should fix this.
Comment #27
Wim LeersComment #28
marcvangendThanks Wim. Test result is green now.
Comment #29
Wim LeersThank you so much, @marcvangend!
I finally did update the issue summary. I incorporated #9 in it. I made the next steps more detailed. Would you be interested in tackling remaining task #3 too? It's a very interesting part of Drupal IMHO 🤓🤞
Comment #30
Wim LeersAaaaaaaactually … I think that that remaining task #3 would make for a great follow-up. Did that: #3259795: Generalize textPartLanguage's validation: no configuration allowed unless the plugin's toolbar item is active.
Comment #31
marcvangendSo if I'm not mistaken, there is no more work to be done here.
Comment #32
Wim LeersSorry, YES! I just can't RTBC this because I wrote the fix. Definitely needs review!
Comment #33
LendudeIn that case, I'll review :)
Fix looks good, we have a failing => passing test that looks great.
NB. The test was moved the a more logical spot, the new test fully covers the deleting of the test in the old spot, great!
Comment #34
Wim LeersDiscussed with @lauriii. We agreed that his suggestion makes sense — it was only a matter of subjective clarity and objective robustness. We're on the same page now 👍
Comment #35
LendudeThis is indeed more robust, so +1 on that change, nice one.
Leaving RTBC since it never got moved away from that.
Comment #39
lauriiiCommitted 88a8d35 and pushed to 10.0.x. Cherry-picked to 9.4.x and 9.3.x because this fixes a major bug and CKEditor 5 is experimental. Thanks!
Comment #40
marcvangendFollow-up #3259555: Organize and rename CKEditor 5 tests and test classes is ready to be reviewed.