Problem/Motivation

With #3362386: CKEditor 5 should respect <textarea disabled>, the CKEditor is set to read-only mode during creation if the textarea is disabled.

But the textarea can also be disabled or enabled dynamically, e.g. via Conditional Form Fields.

Steps to reproduce

  • Configure the #states property to dynamically set the disabled property (or use Conditional Fields) of a CKEditor field.
  • Notice that the read-only mode of the CKEditor is only set once at the start, but not dynamically.

Proposed resolution

Use a MutationObserver to observe the disabled attribute of the textarea and set the read-only mode dynamically.

Remaining tasks

  • implement tests
  • implement solution

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

The CKEditor 5 read-only mode is now set dynamically dependent on the disabled attribute of the textarea. Previously, it was only set once at initialization.

Issue fork drupal-3578477

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:

Comments

tgauges created an issue. See original summary.

tgauges’s picture

Assigned: tgauges » Unassigned
Issue summary: View changes
Status: Active » Needs review

I implemented my solution in !15058, please take a look.

I also needed to update AssetAggregationAcrossPagesTest, presumably because of the increased size of ckeditor5.js. Is that correct?

smustgrave’s picture

Status: Needs review » Needs work

99% there just some comments on the MR.

tgauges’s picture

Status: Needs work » Needs review

Thanks for the review. All the review comments have been fixed with https://git.drupalcode.org/project/drupal/-/merge_requests/15058/diffs?commit_id=fa6540948b6ff6e50c34dacedef951129dc0603f.

Please re-review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Bug Smash Initiative, +Needs Review Queue Initiative

Believe this one is ready to go, working as expected.

alexpott’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed 58b9d70 and pushed to main. Thanks!

We need backport to 11.x

  • alexpott committed 58b9d70d on main
    fix: #3578477 CKEditor 5 should respect <textarea disabled> dynamically...

tgauges’s picture

MR against 11.x: !15586

alexpott’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

Thanks for doing the backport.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4b4ace1 and pushed to 11.x. Thanks!

It conflicts with 11.3.x - @tgauges - if you want to backport it to there feel free to re-open and set to patch to be ported and make the branch.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 4b4ace19 on 11.x
    fix: #3578477 CKEditor 5 should respect <textarea disabled> dynamically...

Status: Fixed » Closed (fixed)

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