I noticed today that when I have submitted a form that has an error the item gets special css treatment (generally making it red) and is highlighted on the page.

However, I still have to click on that form element to get to fix it.

It would be nice if the focus were set to the first form element which is in error so that it can be quickly edited. If multiple elements are in error, I think the first one is the best place to set the focus.

This issue is present also in D8, exactly when adding media image, the scroll does not make first input in error in focus.

CommentFileSizeAuthor
#9 scrollNotComplete (002).png59.18 KBnasser_

Comments

bradlis7’s picture

A simple jquery call would be simple.

$(":input.error:first").focus();
greggles’s picture

Issue tags: +Accessibility

Let's see what the accessibility folks say about this.

mgifford’s picture

Everett, I don't think that link refers to the resolution being discussed. I suspect that there's now an icon there as well as the red message that @greggles was describing. However, it's about setting the focus that a user would automatically start typing into the field that contains the error.

@greggles I think this would be fine from an accessibility standpoint. Might have some usability issues, but changing focus as @bradlis7 suggested (in 2007!) should be just fine as far as I am aware.

Everett Zufelt’s picture

I'm not certain that tit is necessarily the best practice to set focus on the ffirst field with an error. This would not necessarily be expected behavior and could confuse some users, perhaps some screen-reader users, who now have to do more work to build up context for where they are on the page.

I'm not saying that we shouldn't do this, just that it needs to be discussed further to make sure that it is in the best interest of all users.

mgifford’s picture

Version: 7.x-dev » 8.x-dev

Let's put this off for D8 then.

bowersox’s picture

Would setting focus cause browsers to scroll down to that point to bring the field on-screen? On long forms this could cause the toolbar and status/error messages to be off-screen.

I believe that setting focus mid-page would also cause screen-readers to start reading at the point where focus is. Is that correct?

For D8 I would like each form field with an error to have a link in the error message that jumps down to that field. We got that done for required fields for D7, but not for all other field errors. FAPI needs to change to support that.

Everett Zufelt’s picture

Status: Active » Closed (won't fix)

@Brandon

This would cause screen-readers to focus on the field on page load.

Pretty much against this since it is not expected behavior and will cause problems for some users.

Should anyone feel strongly about putting this in Core (it can be added in contrib) please re-open with rationale.

nasser_’s picture

Version: 8.0.x-dev » 8.4.x-dev
Category: Feature request » Bug report
Issue summary: View changes
Status: Closed (won't fix) » Active
Issue tags: -Accessibility +media, +D8Media
StatusFileSize
new59.18 KB

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pameeela’s picture

Status: Active » Closed (won't fix)

Hmm, this was closed by @Everett Zufelt in 2011, and only reopened in 2017 without any comment. I think that this has been superseded by a number of other issues discussing form validation including #1797438: HTML5 validation is preventing form submit and not fully accessible, and since this hasn't had any further discussion I'm going to close it again.