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:
@@ -128,6 +128,7 @@ final class PhabricatorTOTPAuthFactor extends PhabricatorAuthFactor {
|
|||||||
->setLabel(pht('TOTP Code'))
|
->setLabel(pht('TOTP Code'))
|
||||||
->setName('totpcode')
|
->setName('totpcode')
|
||||||
->setValue($code)
|
->setValue($code)
|
||||||
|
->setAutofocus(true)
|
||||||
->setError($e_code));
|
->setError($e_code));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
final class PHUIFormNumberControl extends AphrontFormControl {
|
final class PHUIFormNumberControl extends AphrontFormControl {
|
||||||
|
|
||||||
private $disableAutocomplete;
|
private $disableAutocomplete;
|
||||||
|
private $autofocus;
|
||||||
|
|
||||||
public function setDisableAutocomplete($disable_autocomplete) {
|
public function setDisableAutocomplete($disable_autocomplete) {
|
||||||
$this->disableAutocomplete = $disable_autocomplete;
|
$this->disableAutocomplete = $disable_autocomplete;
|
||||||
@@ -13,6 +14,15 @@ final class PHUIFormNumberControl extends AphrontFormControl {
|
|||||||
return $this->disableAutocomplete;
|
return $this->disableAutocomplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setAutofocus($autofocus) {
|
||||||
|
$this->autofocus = $autofocus;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAutofocus() {
|
||||||
|
return $this->autofocus;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getCustomControlClass() {
|
protected function getCustomControlClass() {
|
||||||
return 'phui-form-number';
|
return 'phui-form-number';
|
||||||
}
|
}
|
||||||
@@ -34,6 +44,7 @@ final class PHUIFormNumberControl extends AphrontFormControl {
|
|||||||
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
||||||
'autocomplete' => $autocomplete,
|
'autocomplete' => $autocomplete,
|
||||||
'id' => $this->getID(),
|
'id' => $this->getID(),
|
||||||
|
'autofocus' => ($this->getAutofocus() ? 'autofocus' : null),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user