1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-22 19:49:02 +01:00

Autofocus form control for adding TOTP codes

Summary: Ref D20122. This is something I wanted in a bunch of places. Looks like at some point the most-annoying one (autofocus for entering TOTOP codes) already got fixed at some point.

Test Plan: Loaded the form, got autofocus as expected.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D20128
This commit is contained in:
Austin McKinley 2019-02-07 11:32:48 -08:00
parent a46c25d2ba
commit f2236eb061
2 changed files with 12 additions and 0 deletions

View file

@ -128,6 +128,7 @@ final class PhabricatorTOTPAuthFactor extends PhabricatorAuthFactor {
->setLabel(pht('TOTP Code'))
->setName('totpcode')
->setValue($code)
->setAutofocus(true)
->setError($e_code));
}

View file

@ -3,6 +3,7 @@
final class PHUIFormNumberControl extends AphrontFormControl {
private $disableAutocomplete;
private $autofocus;
public function setDisableAutocomplete($disable_autocomplete) {
$this->disableAutocomplete = $disable_autocomplete;
@ -13,6 +14,15 @@ final class PHUIFormNumberControl extends AphrontFormControl {
return $this->disableAutocomplete;
}
public function setAutofocus($autofocus) {
$this->autofocus = $autofocus;
return $this;
}
public function getAutofocus() {
return $this->autofocus;
}
protected function getCustomControlClass() {
return 'phui-form-number';
}
@ -34,6 +44,7 @@ final class PHUIFormNumberControl extends AphrontFormControl {
'disabled' => $this->getDisabled() ? 'disabled' : null,
'autocomplete' => $autocomplete,
'id' => $this->getID(),
'autofocus' => ($this->getAutofocus() ? 'autofocus' : null),
));
}