Hi,
I’m curious what removing this tabindex would achieve – could you fill me in? Is this an accessibility issue? Is it conflicting with something else on your page?
As you would already have noticed, this plugin removes the tabindexes that are usually applied to Gravity Forms form fields. The tabindex you’re referring to however is a -1 and is there as one of the measures to make the error validation message take the focus as soon as loads. By doing this, if there are errors an AT user should instantly know that the form submission (or page change) was not successful, know why and be able to navigate to the fields with errors.
This focus is applied only when the error message is displayed and is done by:
- Using
tabindex='-1'
on the error message DIV
- Using
aria-live='assertive' role='alert'
on the error message DIV
- Using JavaScript to set the focus to the DIV, using
window.location.hash = '#error';
- Using jQuery to set the focus to the DIV, using
$(this).find('.validation_error').focus();
- Using jQuery to set the window position to the top of the DIV, using
$(this).scrollTop($('.validation_error').offset().top);
So there’s already a lot of measure in place to make this behaviour work, and I’m willing to remove it from the source code – but I just want to make sure it’s the right thing to do.
Here’s what WebAim have to say about tabindex -1
Keyboard Accessibility – Tabindex
and another article that briefly covers when it is OK to use tabindex -1
Don’t Use Tabindex Greater than 0
From reading these, I’m thinking people generally hate tabindex because it’s been used wrong too often, but it’s still a valid technique when programmatically setting the focus using -1. The issue with this of course is it makes the user skip past the ‘skip to contents’ – but the other measures (listed above) already do this – but that’s OK because we really do want AT users to know that there were errors rather than have to hunt through the page content every page load to see if the error message is there.
So please, let me know your perspective, the pro’s and con’s or if you have knowledge of where this causes accessibility issues. From here I’m seeing it is valid HTML, passes the WCAG 2.0 AA spec and using Firefox,IE,Chrome and JAWS performs as expected.
In the meanwhile, if you want to remove it from your copy of the plugin, you can edit the gravity_forms_wcag20_form_fields_plugin.php file, at line 67 change
FROM
$message .= "<div class='validation_error' tabindex='-1'>";
TO
$message .= "<div class='validation_error'>";