1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 14:51:06 +01:00

On login forms, autofocus the "username" field

Summary: Depends on D20120. Fixes T8907. I thought this needed some Javascript nonsense but Safari, Firefox and Chrome all support an `autofocus` attribute.

Test Plan: Loaded login page with password auth enabled in Safari, Firefox, and Chrome; saw username field automatically gain focus.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T8907

Differential Revision: https://secure.phabricator.com/D20122
This commit is contained in:
epriestley 2019-02-06 20:53:25 -08:00
parent 8054f7d191
commit 949afb02fd
3 changed files with 13 additions and 0 deletions

View file

@ -112,6 +112,7 @@ final class PhabricatorLDAPAuthProvider extends PhabricatorAuthProvider {
id(new AphrontFormTextControl())
->setLabel(pht('LDAP Username'))
->setName('ldap_username')
->setAutofocus(true)
->setValue($v_user)
->setError($e_user))
->appendChild(

View file

@ -229,6 +229,7 @@ final class PhabricatorPasswordAuthProvider extends PhabricatorAuthProvider {
id(new AphrontFormTextControl())
->setLabel(pht('Username or Email'))
->setName('username')
->setAutofocus(true)
->setValue($v_user)
->setError($e_user))
->appendChild(

View file

@ -5,6 +5,7 @@ final class AphrontFormTextControl extends AphrontFormControl {
private $disableAutocomplete;
private $sigil;
private $placeholder;
private $autofocus;
public function setDisableAutocomplete($disable) {
$this->disableAutocomplete = $disable;
@ -24,6 +25,15 @@ final class AphrontFormTextControl extends AphrontFormControl {
return $this;
}
public function setAutofocus($autofocus) {
$this->autofocus = $autofocus;
return $this;
}
public function getAutofocus() {
return $this->autofocus;
}
public function getSigil() {
return $this->sigil;
}
@ -49,6 +59,7 @@ final class AphrontFormTextControl extends AphrontFormControl {
'id' => $this->getID(),
'sigil' => $this->getSigil(),
'placeholder' => $this->getPlaceholder(),
'autofocus' => ($this->getAutofocus() ? 'autofocus' : null),
));
}