- Issue created by @anjaliprasannan
- Merge request !683Issue #3530683: Toolbar in ckeditor disappears when no plugins are selected in ai assistant → (Open) created by Unnamed author
- 🇮🇳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 , saveMoving to Need work . Please check the issue.
- 🇮🇳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 , saveMoving 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 agit 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 displayedcan be moved to RTBC.
- 🇮🇳India prashant.c Dharamshala
Thanks, overall working well.
A few suggestions left on the MR, please check.
- 🇮🇳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) - 🇮🇳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.
- 🇮🇳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 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.