Problem/Motivation

Related to #3215835: Hidden button config textarea should not be keyboard navigable and that's what made me realize I should report this:

$form_state->setErrorByName('toolbar][items', $this->t('Toolbar items must be written as an array of strings, e.g. ["bold","italic","|","uploadImage"]'));
triggers:

(Note the absence of error styles.)

Steps to reproduce

  1. Configure text editor to use CKEditor 5. Make sure it has at least one button in the toolbar (say, bold).
  2. Go to /admin/config/development/configuration/single/export and export it
  3. Replace one of the buttons (say bold) with a non-existent toolbar item, say nonsense.
  4. Import this at /admin/config/development/configuration/single/import
  5. Go back to the configuration form for this text format/editor and hit Save
  6. Result:
  7. (Note how there's no highlighting for the toolbar item that's at fault, even though the error message does target it.)

Proposed resolution

TBD

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#4 Screenshot 2021-08-11 at 10.42.17.png209.85 KBwim leers

Comments

Wim Leers created an issue. See original summary.

lauriii’s picture

Is there a way to get that error triggered? If I disable JavaScript and change the value to something other than an array, I'm getting an uncaught exception:

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 110 of modules/ckeditor5/src/Plugin/CKEditor5Plugin/ImageUpload.php).
in_array('uploadImage', NULL) (Line: 110)
Drupal\ckeditor5\Plugin\CKEditor5Plugin\ImageUpload->validateImageUploadSettings(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 280)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 236)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 236)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 236)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 236)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 236)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 236)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'filter_format_edit_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('filter_format_edit_form', Array, Object) (Line: 589)
Drupal\Core\Form\FormBuilder->processForm('filter_format_edit_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 34)
Drupal\form_test\StackMiddleware\FormTestMiddleware->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 716)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
lauriii’s picture

I'm also wondering if the error message makes sense in the use case where JavaScript is enabled. It is not a user error but a system error in that case because for some reason the toolbar was generated incorrectly. Why it doesn't make sense is that the error message is telling the user to write the array in a certain way, but they don't even have a way to view that without using developer tools in their browser.

wim leers’s picture

Issue summary: View changes
Priority: Normal » Minor
StatusFileSize
new209.85 KB

Agreed. This is extremely pedantic of me 🙈. Not once have I actually seen this problem occur.

Just when I wanted to mark this Closed (works as designed), I found a way to reproduce this.

Marking this Minor because it is … pretty obscure 😅

wim leers’s picture

Project: CKEditor 5 » Drupal core
Version: 1.0.x-dev » 9.3.x-dev
Component: User interface » ckeditor5.module

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now 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.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now 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: 10.1.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, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.