Follow-up to #1493324: Inline form errors for accessibility and UX

Currently postponed on #1870006-10: HTML5 validation with table sticky header is misaligned over the toolbar.

Problem

The inline error massage handling is great, but it's a nuisance to be snapped to the form (input) element related to the error instead of the elements title (a user should be able to see what the field is about).

Related: in case the menu toolbar is enabled the form element is often not visible at all (below the top bar). #1440628: [Meta] javascript toolbar/tableheader with url fragment mess

Proposed Resolution

It would seem that all form field errors get an error wrapper around them so let's always jump to it, instead of the form element itself.
We could add a dedicated anchor tag above the field label and/or fieldset.
Add an ID to the form element labels and point the links to those ID's instead of the ID of the input element.
This will allow the user to see the form label and any instructions that are pertinent to resolving said error.

Remaining tasks

  • Update error message link target to point to error message wrapper (Not relevant anymore)
  • Add dedicated anchors above field labels and fieldsets (Not valid HTML5)
  • Research if the focus goes to the target input element when we jump to labels.
  • Add ID's to field labels
  • Point inline error links to the anchors labels when present, and the input element otherwise

animated gif of problem.

CommentFileSizeAuthor
inline_form_errors-1493324.gif482.51 KBBLadwin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BLadwin’s picture

Issue summary: View changes
BLadwin’s picture

I marked this as a minor issue, as the error message does take you to the form field in question. This is a minor tweak to the functionality, but seems more cosmetic than functional. If my assumption of this after reading https://www.drupal.org/core/issue-priority is incorrect, please rectify and update the issue priority.

vijaycs85’s picture

Status: Active » Postponed
dmsmidt’s picture

Title: Inline form errors should jump to error container, not form element » Inline form error links should bring form element title, form element and the error in view.
Priority: Minor » Normal
Issue summary: View changes
Status: Postponed » Active
Issue tags: +toolbar

Currently the error messages are in most cases below the fields. So the problem is less problematic in this regard.
However, in some cases the message are still above the input elements (fieldset, checkboxes, password change, etc.).

I find it also problematic that the field titles are not visible anymore after jumping to the problematic field.

A good solution would be to not target the ID of the form elements but to add dedicated anchors above the labels and target those add an ID to the label (if there is a label) and target those.
(This also means we don't need the wrapping error-div back, jay).

There is another problem: when there is a top menu bar, the error message and input item are often below the bar.
This is even a bigger problem than the original because it can seriously confuse the user.
In fact it is a more general problem: when using the admin toolbar the targeted content will always be (partly) invisible after the jump.
Using a dedicated anchor tag could also prove part of the solution for this extra problem (using css offsets).
I'll create an issue for the toolbar to address this problem.

Edit: <a name='foo'></a> is no valid HTML5, change comment

nod_’s picture

dmsmidt’s picture

Issue summary: View changes

#5 @nod_ Thanks for pointing out that issue.

dmsmidt’s picture

deleted

dmsmidt’s picture

Issue tags: +drupaldevdays
dmsmidt’s picture

Issue summary: View changes
dmsmidt’s picture

Issue summary: View changes

We should check that if we jump to the labels, the fields still get focus somehow.

xjm’s picture

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mgifford’s picture

Issue summary: View changes
andrewmacpherson’s picture

Component: forms system » inline_form_errors.module
SKAUGHT’s picture

perhaps this should only be a drupal.behaviour to scroll to the top of the form-item. then, keeping focus on the input itself.

reminder:
#2560467: Inline Errors not shown for container elements -- containers don't have labels/legend.

dmsmidt’s picture

Status: Active » Postponed

Also, it becomes more common to not have a label at all, in favor of a placeholder. So this functionality shouldn't break if someone removes the label (via code).

I think we should by default still jump to the id of the form field, but indeed use some JS to get the label in view IF it is present.
We should wait for #1870006-10: HTML5 validation with table sticky header is misaligned over the toolbar and could improve that patch later, by instead of bringing the element (field) into view, to bring the closest label into view if present.

rootwork’s picture

Issue summary: View changes
Related issues:

I've updated the summary with a note saying this is postponed on #1870006-10: HTML5 validation with table sticky header is misaligned over the toolbar.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.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.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.