Toolbar in ckeditor disappears when no plugins are selected in ai assistant.

Created on 18 June 2025, about 2 months ago

Problem/Motivation

Toolbar in ckeditor diappears when ai assistant icon is added to active toolbar of text formats and no plugins are enabled. Here we will require a error message to select atleast one tool for the ai tools.

Steps to reproduce

In any of the text formats add the ai assistant to the active toolbar
Save the configuration without enabling any plugin tools.
Go to content and edit any content with ckeditor field and you find the ckeditor toolbar is not available for the text format having ai assistant enabled.

Proposed resolution

Add an error message to select at least one tool from ai tools on save configuration if no tools selected.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.2

Component

AI CKEditor

Created by

🇮🇳India anjaliprasannan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @anjaliprasannan
  • Pipeline finished with Success
    about 2 months ago
    #525024
  • 🇮🇳India divya.sejekan

    Applied MR!683 , I can see error messages displayed in setting for AI. But i think we should get error only for AI provider field not all since some default value is already selected.
    But there is issue , if i remove AI from the active tool bar its not allowing me to save.

    Issues Summary :
    1. Should get error only for AI provider field
    2. if removed AI from the active tool bar its not allowing to save.

    Steps followed :
    1. Enabled AI module
    2. Added AI ckeditor in active toolbar , Save
    3. Remove AI from active tool bar , save

    Moving to Need work . Please check the issue.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 212s
    #527244
  • Pipeline finished with Success
    about 2 months ago
    Total: 287s
    #527304
  • 🇮🇳India anjaliprasannan

    @divya.sejekan
    I have fixed the issue. Please review.

    Among your points
    1. Should get error only for AI provider field
    This is not valid as we discussed via slack.

    2. if removed AI from the active tool bar its not allowing to save.
    This I have fixed. Please review.

  • 🇮🇳India divya.sejekan

    hi @anjaliprasannan . I tried again with the updated patch. Still im not able to save after removing the AI tool from the Active Toolbar. Still getting the error.
    Steps followed :
    1. Enabled AI module
    2. Added AI ckeditor in active toolbar , Save
    3. Remove AI from active tool bar , save

    Moving to Need work . Please check the issue.

  • 🇮🇳India anjaliprasannan

    @Divya
    I have rechecked. The changes are reflecting properly. Attaching a working screencast.

    Please checkout to the branch using this git checkout '3530683-toolbar-in-ckeditor' command then do a git pull, git drush cr to review the changes.

  • 🇮🇳India sarvjeetsingh

    Hi!
    I've reviewed and tested MR ! following the steps provided in comment #8. Can confirm the fix is working as expected.

    Steps Followed:

    Enabled AI module and dependencies
    Added AI CKEditor button to active toolbar - saved successfully
    Removed AI button from active toolbar - now saves without validation errors (fixed)
    Verified that when AI button is present but no AI tools are selected, appropriate validation message is displayed

    can be moved to RTBC.

  • 🇮🇳India prashant.c Dharamshala

    Thanks, overall working well.

    A few suggestions left on the MR, please check.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 385s
    #535812
  • Pipeline finished with Success
    about 1 month ago
    Total: 210s
    #535819
  • 🇮🇳India sijumpk

    After moving the "AI CKEditor" button from Available buttons to Active toolbar, there is a delay for the "AI tools" options to appear under "CKEditor 5 plugin settings". If we submit the form without waiting for the options to appear, submission is ending up in a php error. Similar constrain implementation is there in Heading plugin, but its not breaking the form submission even if we submit the form before options appearance. Plz find the screenrecording of the same. Apart from this, the validation is happening correctly and the toolbar disappearing issue is not happening after the patch.

    The website encountered an unexpected error. Try again later.

    AssertionError: assert(NestedArray::keyExists($subform, $parts)) in assert() (line 857 of core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php).
    Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapViolationPropertyPathsToFormNames() (Line: 893)
    Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapPairViolationPropertyPathsToFormNames() (Line: 678)
    Drupal\ckeditor5\Plugin\Editor\CKEditor5->validateConfigurationForm() (Line: 59)
    editor_form_filter_admin_format_validate()
    call_user_func_array() (Line: 82)
    Drupal\Core\Form\FormValidator->executeValidateHandlers() (Line: 275)
    Drupal\Core\Form\FormValidator->doValidateForm() (Line: 118)
    Drupal\Core\Form\FormValidator->validateForm() (Line: 585)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 321)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 622)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)

  • Pipeline finished with Canceled
    26 days ago
    #543948
  • Pipeline finished with Failed
    26 days ago
    Total: 207s
    #543954
  • Pipeline finished with Failed
    26 days ago
    Total: 437s
    #543970
  • Pipeline finished with Failed
    26 days ago
    Total: 182s
    #543981
  • Pipeline finished with Failed
    26 days ago
    Total: 190s
    #543994
  • Pipeline finished with Failed
    26 days ago
    Total: 186s
    #544012
  • Pipeline finished with Failed
    26 days ago
    Total: 1930s
    #544030
  • Pipeline finished with Failed
    26 days ago
    Total: 191s
    #544077
  • Pipeline finished with Success
    26 days ago
    Total: 210s
    #544689
  • Pipeline finished with Success
    26 days ago
    Total: 285s
    #544691
  • 🇮🇳India sijumpk

    sijumpk changed the visibility of the branch 1.2.x to hidden.

  • Pipeline finished with Success
    26 days ago
    Total: 367s
    #544699
  • 🇮🇳India sijumpk

    The issue was caused by the missing import of ViewModel from aiui.js in some earlier commits. This import has now been restored. Additionally, the previously added constraint validation has been removed. As a result, the AI CKEditor plugin will no longer appear in the editor if no sub-plugins are configured. Since this is a JavaScript-level fix, clearing browser caches is recommended before testing the changes.

  • 🇮🇳India anjaliprasannan

    Reviewed the changes. It working fine.
    Attaching before and after

  • 🇩🇪Germany marcus_johansson

    Wouldn't it be possible to just validate this when you save the filter format? There is no reason to add the button, if you do not enable something.

  • Pipeline finished with Failed
    19 days ago
    Total: 202s
    #550928
  • 🇮🇳India sijumpk

    @marcus_johansson, the initial approach in this ticket was to add a validation to the filter format form, making sub-plugins mandatory if the AI CKEditor plugin is enabled. It was working well. However, we encountered a minor timing issue: there's a slight delay before the subform appears after dragging the AI CKEditor plugin into the toolbar. If the form is submitted during that delay, the validation doesn’t trigger correctly, resulting in an error at the CKEditor 5 module level.

    This behavior is demonstrated in #12 🐛 Toolbar in ckeditor disappears when no plugins are selected in ai assistant. Active . Even if we were to bypass validation in such a case, the end result would still be a broken toolbar due to the missing sub-plugins—similar to the original issue.

    An alternative would be to enable at least one sub-plugin (such as Help and Support) by default. For example, the Heading CKEditor plugin has a similar safeguard: it enforces validation and ensures some heading options are enabled by default to avoid breakage.

    With the current implementation, if no sub-plugins are selected, the AI CKEditor button simply won't appear in the toolbar—which aligns with what you pointed out: we're not explicitly adding any button ourselves. Attaching a demo of the current behavior for reference.

    Another possible approach is to combine the validation in the filter format form (which @anjaliprasannan already developed as part of this issue) with the current JavaScript-level fix. In this case, if the AI CKEditor plugin is enabled for the first time and the timing issue occurs during form submission, we can skip the validation just for that initial scenario. This ensures the toolbar works without any issues. Then, on subsequent edits to the filter format form, users would be required to either enable at least one sub-plugin or remove the AI CKEditor plugin. Let us know your thoughts.

  • 🇮🇳India sijumpk

    Awaiting feedback from module maintainers.

  • 🇮🇳India roshanibhangale

    Hi

    I have tested this ticket on 11.x and its working appropriately.

    Steps to reproduce

    • Enable the AI module and AI CKEditor integration.
    • Add AI CKEditor in active toolbar and save.
    • Go to content and edit any content with CKEditor field and observe that the CKEditor toolbar is available.

    After applying the patch successfully, Observed that the toolbar is present after adding the AI assistance icon.

    Hence this can be moved to RTBC +1. Attaching the screenshot for the reference.

Production build 0.71.5 2024