Problem/Motivation

See #2729663: Fragment link pointing to <textarea> should be redirected to CKEditor instance when CKEditor replaced that textarea. Same problem with CKEditor 5.

Steps to reproduce

Trigger a validation error on a text field using CKEditor 5 while Inline Form Errors is enabled.

Proposed resolution

Implement a solution similar to #2729663: Fragment link pointing to <textarea> should be redirected to CKEditor instance when CKEditor replaced that textarea.

When suggested to implement this upstream, the CKEditor developers reacted surprised: they've never seen this requested before. Since it's simple enough to implement and maintain on our side, the above seems fine.

Remaining tasks

  1. Port test coverage from \Drupal\Tests\ckeditor\FunctionalJavascript\CKEditorIntegrationTest::testFragmentLink().
  2. Port test coverage from \Drupal\Tests\inline_form_errors\FunctionalJavascript\FormErrorHandlerCKEditorTest().
  3. Add fix.

User interface changes

Fragment link navigation pointing to text fields using CKEditor 5 now works.

API changes

None.

Data model changes

None.

Issue fork drupal-3238257

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Project: CKEditor 5 » Drupal core
Version: 1.0.x-dev » 9.3.x-dev
Component: Code » ckeditor5.module
Issue tags: +Needs tests

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.

hooroomoo made their first commit to this issue’s fork.

hooroomoo’s picture

Test is currently expected to fail because it is using the wrong $ckeditor_id but not sure why it is failing on the "assertNotVisibleInViewport" assertion on line 104.

hooroomoo’s picture

Status: Active » Needs review

Works when manually tested but still unsure why line 107 which has the "assertNotVisibleInViewport" assertion in the CKEditor5FragmentLinkTest.php file keeps failing.

Could also use a review before I add another test for this in inline-error form.

ranjith_kumar_k_u’s picture

Fixed CS errors.

Status: Needs review » Needs work

The last submitted patch, 8: 3238257-8.patch, failed testing. View results

Wim Leers’s picture

@ranjith_kumar_k_u Can you please commit your change to the merge request instead? By uploading a patch, you introduced a parallel path 😅

Wim Leers’s picture

Issue tags: -Needs tests

This is definitely on the right track 😊

Let's first try to get tests to pass — I posted a suggestion that I think will fix this.

Then let's try to tackle that "unique URL on every redirect" problem.

hooroomoo’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

Fixing credit

Wim Leers’s picture

Priority: Normal » Major
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Accessibility, +JavaScript

Almost there!

Issue summary updated. After my feedback is addressed, this will be RTBC :) Also bumping this to Major because without this, CKEditor 5 will regress compared to CKEditor 4 when using Inline Form Errors for improved accessibility. Plus, the equivalent CKEditor 4 issue was Major too: #2729663: Fragment link pointing to <textarea> should be redirected to CKEditor instance when CKEditor replaced that textarea.

hooroomoo’s picture

Status: Needs work » Needs review
Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Manually tested one last time; works great!

All my concerns have been addressed.

Thanks, @hooroomoo!

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

This needs a Drupal 10 patch 😇

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
10.42 KB
10.55 KB

Uploading both D9 and D10 patches extracted directly from the latest MR (the only difference being that I ran cd core && yarn install && yarn build:js again for the D10 patch), which makes it easy to compare what's different between the two. Basically: var vs const, due to #3253148: Remove IE from core's browserlist, remove non-essential CSS importing and recompile assets.

P.S.: due to #3253148: Remove IE from core's browserlist, remove non-essential CSS importing and recompile assets we're going to have to create D10 patches for any JS change that affects Drupal-owned JS for the CKEditor 5 module 😬

  • lauriii committed 241794b on 10.0.x
    Issue #3238257 by hooroomoo, Wim Leers: Fragment link pointing to...

  • lauriii committed 365cb3a on 9.4.x
    Issue #3238257 by hooroomoo, Wim Leers: Fragment link pointing to...

  • lauriii committed 6c0fe61 on 9.3.x
    Issue #3238257 by hooroomoo, Wim Leers: Fragment link pointing to...
lauriii’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 241794b and pushed to 10.0.x. Committed the Drupal 9 patch to 9.4.x and cherry-picked to 9.3.x because CKEditor 5 is still experimental. Thanks!

Status: Fixed » Closed (fixed)

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