The user_login form is the only form in Drupal core that defines a tabindex attribute:
function user_login(&$form_state) {
...
$form['name'] = array('#type' => 'textfield',
'#title' => t('Username'),
...
'#attributes' => array('tabindex' => '1'),
);
$form['pass'] = array('#type' => 'password',
'#title' => t('Password'),
...
'#attributes' => array('tabindex' => '2'),
);
...
$form['submit'] = array('#type' => 'submit', '#value' => t('Log in'), '#weight' => 2, '#attributes' => array('tabindex' => '3'));
return $form;
}
Specifying the tabindex is however not required as the natural order of the fields (username, password, submit) in the markup already provides the desired usability/accessibility.
Moreover, the presence of the tabindex makes it a bit unnecessary hard/messy to add an accessible CAPTCHA element between the password field and submit button: #128550: Tab Key on User Login Form passowrd field jumps to 'submit' button instead of captcha field. I guess there are other cases of form_altering that suffer from the same problem.
The attached patch removes the tabindex attributes from the user_login form.
Comments
Comment #1
damien tournoud commentedInteresting bit of history, lying there. Those should obviously go away.
Comment #2
dries commentedCommitted to CVS HEAD. Thanks.
Comment #3
soxofaan commentedThanks,
any chance the backport for D6 can get in?
Comment #4
damien tournoud commentedI support the backport too. It shouldn't hurt.
Comment #5
gábor hojtsyWell, I guess you could have altered the tabindex just as well. Anyway, makes sense to commit to Drupal 6 too. Done!