Problem/Motivation
Follow-up to #3231321: Improve keyboard accessibility in a particular edge case, the form id can be random when there are errors on the form and the form id that is supposed to be #filter-format-edit-form looks like this: id="filter-format-edit-form--caLhw-Q-8ME". It causes a JS error to be triggered in the console when clicking on any vertical-tab title for the plugin config.
Steps to reproduce
- Edit a CKE5 text format
- Add the Image plugin but do not enable image upload (it will triggers an error on submit).
- Try to save the form
- Interact with the vertical tab of the cke5 plugin settings
- JS error:
Uncaught TypeError: Cannot read properties of null (reading 'hasAttribute') at updateUiStateStorage (ckeditor5.admin.js:404:34) at HTMLUListElement.<anonymous> (ckeditor5.admin.js:456:13)
Proposed resolution
Code need to be using form[data-drupal-selector="filter-format-edit-form"] instead of the form ID.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 3263601-18.patch | 4.88 KB | wim leers |
| #18 | 3263601-18-do-not-test.patch | 2.25 KB | wim leers |
Issue fork drupal-3263601
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
Comment #3
kostyashupenkoFor some reason on this form
data-drupal-selectorattribute can be also random after submit + when system messages appears after submit. But i believe this attribute should be static no matter what. So for sure it needs to be fixed first and then we can update js.Comment #5
wim leersWow, great find!
I think it is probably okay to land this without explicit test coverage. But let's see if others agree with that.
Pinging @nod_ to review this — he's done a lot of work on the "ID to
data-drupal-selector" transition :)Comment #6
nod_Looks like a duplicate of #2897377: $form['#attributes']['data-drupal-selector'] is set to a random value so can't be used for its intended purpose that we ran into a while ago.
Comment #7
wim leersHm … is it really though?
Isn't the problem that the JS is looking for elements based on
idattribute instead of based ondata-drupal-selectorattribute? 🤔Comment #8
nod_right not a duplicate per say, related issue is about the backend problem we're seeing that makes the JS patch useless.
While the backend issue is fixed we can use something like
[data-drupal-selector^="form-id…"]to make it work. It's contained enough inside the ckeditor5 module that I don't worry we'll run into problems with the selector matching something that it shouldn't. Haven't tested it but it might even be possible to use[data-drupal-selector|="form-id-…"]https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectorsComment #9
wim leersThe only failure here seems unrelated:
@nod_ So are you proposing we postpone this on #2897377: $form['#attributes']['data-drupal-selector'] is set to a random value so can't be used for its intended purpose? It's not clear to me from your comment 😅
Comment #10
kostyashupenkoAlright, re-fixed it according to #8
Comment #11
nod_Nice, thank you.
2 minor points:
After that I'm good to RTBC :)
Comment #12
kostyashupenkoComment #13
nod_All good, thanks :)
Comment #14
wim leersComment #15
larowlanDoes this issue still persist now that #3254328: Update to Drupal 9.3.0 adding --2 suffix to (views-) block-ID's is in?
Yes we shouldn't be using IDs for selection, but do we still need the
^qualifier?Comment #16
nod_Yes I can confirm this is still happening with the current 10.x branch.
The issue here is with form ids, not blocks, root cause is in the related issue, the
^is a band-aid :)Comment #17
larowlanIs there anyway we can write a test for this?
Comment #18
wim leersStill a bug, can still reproduce it.
We should definitely be able to write a test for this. Here you go.
Comment #19
wim leersTest passed, despite
😬
Comment #20
nod_So the original steps to trigger the error is not possible anymore since we added the possibility to use image plugin without upload enabled. In theory this is still an issue but I couldn't find a way to trigger the problem with the core interface anymore.
I still think we should update the code with what's in the MR (needs reroll) even if we don't have a good way to test this.