Problem/Motivation
In the field UI, when region or plugin fields are changed, an Ajax form is updated by triggering mousedown on a hidden submit element
$('input[data-drupal-selector="edit-refresh"]').trigger('mousedown');
As a result, focus is transferred to this hidden element as seen here
This is a cosmetic problem due to the page scrolling down and an accessibility problem because the focus is not visible
Steps to reproduce
Proposed resolution
Add a mousedown listener to the hidden submit element, use that to keep track of the element that should remain in focus. Then, in a focus listener on that hidden element, immediately return focus back to the element that should be retaining it.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3346300-19-95x.patch | 4.58 KB | bnjmnm |
| #18 | 3346300-18.patch | 3.26 KB | mrinalini9 |
| #6 | 3346300-TEST-ONLY.patch | 1.87 KB | bnjmnm |
Issue fork drupal-3346300
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:
- 3346300-after-using-select
changes, plain diff MR !3589
Comments
Comment #2
whitedevil commentedPlease add the proper steps to reproduce the issue if possible with screenshot, only then someone can look into it and provide the solution.
Comment #4
bnjmnm@whitedevil If you take a look at my profile you might get the sense that this is something I'm aware of. I assigned this issue to myself as I was already aware of how to fix it and did not want anyone to waste their time working on it. As an added level of precaution did not add the issue summary until I had a working MR up. it sounds like this precaution was warranted as there was interest in working on it. It's available for review now, though, so have at it!
Comment #5
smustgrave commentedSeems there is an error in the MR that may be legit, least not the random ckeditor5 one.
Tested for the problem as seen in the video and did confirm the issue.
The change in the MR does fix it also.
Wonder if we could add a test that when the ajax completes focus remains on the field?
Comment #6
bnjmnmComment #7
bnjmnmGood call on the tests, added them + test only patch.
I could not reproduce the test failure in
\Drupal\Tests\node\FunctionalJavascript\SettingSummariesContentTypeTest::testWorkflowSummarythat occured with Drupal CI. I suspect it's a random fail as the one file altered - field_ui.js - is not loaded during this test.Comment #9
bnjmnmComment #10
smustgrave commentedGreat job with the test!
Comment #11
lauriiiWoah this is a significant improvement to the UX of that page 😱 I'm wondering if there's a way to prevent the scrolling from happening altogether? With the MR, I'm still getting some scrolling although it doesn't scroll outside of the viewport completely.
Comment #12
smustgrave commentedEven better!
Comment #16
lauriiiCommitted 09f64bf and pushed to 10.1.x and cherry-picked to 10.0.x. Thanks!
I think this could be backported to 9.5.x but we need to create a separate patch for that.
Comment #17
lauriiiMoving to NW for someone to create the backport patch.
Comment #18
mrinalini9 commentedRerolled patch for 9.5.x branch, please review it.
Thanks!
Comment #19
bnjmnmComment #20
bnjmnmComment #22
lauriiiCommitted de15dcb and pushed to 9.5.x. Thanks!