Skip to content
This repository was archived by the owner on Sep 25, 2018. It is now read-only.

Commit

Permalink
Fix autoFocus input prop spelling and add autoFocus to all forms
Browse files Browse the repository at this point in the history
Adds auto-focus to login and forgotten password/username screens.

Removes this warning:
"Warning: Unknown DOM property autofocus. Did you mean autoFocus?"

fbshipit-source-id: f099362
  • Loading branch information
fson authored and expbot committed Feb 20, 2018
1 parent c8d8599 commit 3853eeb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/ui/auth/ForgotPasswordScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ForgotPasswordScreen extends React.Component {
</p>
<TextInput
ref="username"
autoFocus
styles={styles.input}
type="text"
placeholder="Username or e-mail address"
Expand Down
1 change: 1 addition & 0 deletions src/ui/auth/ForgotUsernameScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class ForgotUsernameScreen extends React.Component {
</p>
<TextInput
ref="username"
autoFocus
styles={styles.input}
type="text"
placeholder="E-mail address"
Expand Down
1 change: 1 addition & 0 deletions src/ui/auth/components/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class LoginForm extends React.Component {
<div style={{ width: 270 }}>
<TextInput
ref="username"
autoFocus
styles={styles.input}
type="text"
placeholder="Username or e-mail address"
Expand Down
4 changes: 2 additions & 2 deletions src/ui/auth/components/RegisterForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class RegisterForm extends React.Component {
<div className={css(styles.fieldContainerInner)}>
<TextInput
ref="givenName"
autofocus
autoFocus
styles={styles.input}
type="text"
placeholder="First name"
Expand Down Expand Up @@ -167,7 +167,7 @@ export default class RegisterForm extends React.Component {
<div className={css(styles.fieldContainerInner)}>
<TextInput
ref="givenName"
autofocus
autoFocus
styles={styles.input}
type="text"
placeholder="First name"
Expand Down
11 changes: 1 addition & 10 deletions src/ui/components/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Props = {
styles?: any,
value?: ?string,
valueTransformer?: (val: string) => string,
autofocus: ?boolean,
autoFocus?: boolean,
};

type State = {
Expand All @@ -38,20 +38,11 @@ export default class TextInput extends React.Component {
return this.state.value.trim();
}

componentDidMount() {
if (this.props.autofocus) {
this._input && this._input.focus();
}
}

render() {
const { styles: extraStyles, valueTransformer, ...inputProps } = this.props;

return (
<input
ref={view => {
this._input = view;
}}
className={css(styles.input, extraStyles)}
{...inputProps}
onChange={this._onValueChange}
Expand Down

0 comments on commit 3853eeb

Please sign in to comment.