From aa8cf504f876182048e1f0e5b72b234b10a7f472 Mon Sep 17 00:00:00 2001 From: Simon Fondrie-Teitler Date: Wed, 26 Apr 2017 20:28:27 -0400 Subject: [feat] Go to first open line when enter is pressed When filling out the signup or login pages, and when adding an additional service provider, the enter key will trigger the submit action. When on the choose provider page, enter will take you to the next page. - Resolves: #8841 --- ui/app/components/main_panel/user_password_form.js | 54 ++++++++++++++++------ 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'ui/app/components/main_panel/user_password_form.js') diff --git a/ui/app/components/main_panel/user_password_form.js b/ui/app/components/main_panel/user_password_form.js index 5e26b198..33640f0c 100644 --- a/ui/app/components/main_panel/user_password_form.js +++ b/ui/app/components/main_panel/user_password_form.js @@ -26,6 +26,7 @@ export default class UserPasswordForm extends React.Component { repeatPassword: null } this.submit = this.submit.bind(this) + this.onKeyPress = this.onKeyPress.bind(this) this.setNew = this.setNew.bind(this) this.setCurrent = this.setCurrent.bind(this) this.setRepeat = this.setRepeat.bind(this) @@ -79,6 +80,22 @@ export default class UserPasswordForm extends React.Component { ) } + onKeyPress(e) { + if (e.key === 'Enter') { + const firstUnfilledField = [ + this.currentPasswordRef, + this.newPasswordRef, + this.repeatPasswordRef, + ].find(ref => ref != null && ref.value == "") + + if (firstUnfilledField) { + firstUnfilledField.focus() + } else { + this.submit(e); + } + } + } + render () { let submitButton = null let message = null @@ -100,21 +117,30 @@ export default class UserPasswordForm extends React.Component { submitButton = } return ( -
+ {message} - - - + this.currentPasswordRef = ref} + label="Current Password" + validationMode="none" + onChange={this.setCurrent} + /> + this.newPasswordRef = ref} + label="New Password" + validationMode="crack" + onChange={this.setNew} + /> + this.repeatPasswordRef = ref} + label="Repeat Password" + validationMode="match" + matchText={this.state.newPassword} + onChange={this.setRepeat} + /> {submitButton} ) -- cgit v1.2.3