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

https://youtu.be/PspRa46ypgU

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

Issue fork drupal-3346300

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

bnjmnm created an issue. See original summary.

whitedevil’s picture

Please add the proper steps to reproduce the issue if possible with screenshot, only then someone can look into it and provide the solution.

bnjmnm’s picture

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

Please add the proper steps to reproduce the issue if possible with screenshot, only then someone can look into it and provide the solution.

@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!

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Seems 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?

bnjmnm’s picture

StatusFileSize
new1.87 KB
bnjmnm’s picture

Status: Needs work » Needs review

Good call on the tests, added them + test only patch.

I could not reproduce the test failure in \Drupal\Tests\node\FunctionalJavascript\SettingSummariesContentTypeTest::testWorkflowSummary that 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.

Status: Needs review » Needs work

The last submitted patch, 6: 3346300-TEST-ONLY.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Great job with the test!

lauriii’s picture

Status: Reviewed & tested by the community » Needs review

Woah 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.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Even better!

  • lauriii committed 09f64bf5 on 10.1.x
    Issue #3346300 by bnjmnm, smustgrave: After using select to change...

  • lauriii committed 67aad0ff on 10.0.x
    Issue #3346300 by bnjmnm, smustgrave: After using select to change...

lauriii’s picture

Version: 10.1.x-dev » 9.5.x-dev

Committed 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.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

Moving to NW for someone to create the backport patch.

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new3.26 KB

Rerolled patch for 9.5.x branch, please review it.

Thanks!

bnjmnm’s picture

StatusFileSize
new4.58 KB
bnjmnm’s picture

Status: Needs review » Reviewed & tested by the community

  • lauriii committed de15dcbd on 9.5.x
    Issue #3346300 by bnjmnm, smustgrave: After using select to change...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed de15dcb and pushed to 9.5.x. Thanks!

Status: Fixed » Closed (fixed)

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