add autoFocus feature to SessionInput

pull/1381/head
Audric Ackermann 5 years ago
parent 357421f161
commit a5a7b38da9
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -404,6 +404,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
<SessionInput <SessionInput
label={window.i18n('recoveryPhrase')} label={window.i18n('recoveryPhrase')}
type="password" type="password"
autoFocus={true}
placeholder={window.i18n('enterRecoveryPhrase')} placeholder={window.i18n('enterRecoveryPhrase')}
enableShowHide={true} enableShowHide={true}
onValueChanged={(val: string) => { onValueChanged={(val: string) => {
@ -413,7 +414,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
this.handlePressEnter(); this.handlePressEnter();
}} }}
/> />
{this.renderNamePasswordAndVerifyPasswordFields()} {this.renderNamePasswordAndVerifyPasswordFields(false)}
</div> </div>
); );
} }
@ -467,7 +468,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
if (signUpMode === SignUpMode.EnterDetails) { if (signUpMode === SignUpMode.EnterDetails) {
return ( return (
<div className={classNames('session-registration__entry-fields')}> <div className={classNames('session-registration__entry-fields')}>
{this.renderNamePasswordAndVerifyPasswordFields()} {this.renderNamePasswordAndVerifyPasswordFields(true)}
</div> </div>
); );
} }
@ -475,7 +476,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
return null; return null;
} }
private renderNamePasswordAndVerifyPasswordFields() { private renderNamePasswordAndVerifyPasswordFields(stealAutoFocus: boolean = false) {
const { password, passwordFieldsMatch } = this.state; const { password, passwordFieldsMatch } = this.state;
const passwordsDoNotMatch = const passwordsDoNotMatch =
!passwordFieldsMatch && this.state.password !passwordFieldsMatch && this.state.password
@ -485,6 +486,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
return ( return (
<div className="inputfields"> <div className="inputfields">
<SessionInput <SessionInput
autoFocus={stealAutoFocus}
label={window.i18n('displayName')} label={window.i18n('displayName')}
type="text" type="text"
placeholder={window.i18n('enterDisplayName')} placeholder={window.i18n('enterDisplayName')}

@ -13,6 +13,8 @@ interface Props {
enableShowHide?: boolean; enableShowHide?: boolean;
onValueChanged?: any; onValueChanged?: any;
onEnterPressed?: any; onEnterPressed?: any;
autoFocus?: boolean;
} }
interface State { interface State {
@ -35,6 +37,7 @@ export class SessionInput extends React.PureComponent<Props, State> {
public render() { public render() {
const { const {
autoFocus,
placeholder, placeholder,
type, type,
value, value,
@ -55,6 +58,7 @@ export class SessionInput extends React.PureComponent<Props, State> {
placeholder={placeholder} placeholder={placeholder}
value={value} value={value}
maxLength={maxLength} maxLength={maxLength}
autoFocus={autoFocus}
onChange={e => { onChange={e => {
this.updateInputValue(e); this.updateInputValue(e);
}} }}

Loading…
Cancel
Save