Skip to content

[IMPROVEMENT] Use autoFocus rather than timeout + focus #1067

@diegolmello

Description

@diegolmello

In some places, text input must be focused automatically on did mount, but we could do it better.
Currently, we're using a setTimeout to wait for navigation transition animation and then a inputRef.focus().
TextInput has a autoFocus prop that does it.

Example: LoginView

// We could remove this entire block and add `autoFocus` on username input and remove unnecessary ref
componentDidMount() {
	this.timeout = setTimeout(() => {
		this.usernameInput.focus();
	}, 600);
}

Where to do it:

  • CreateChannelView
  • ForgotPasswordView
  • LoginView
  • NewServerView
  • RegisterView
  • SearchMessagesView
  • SetUsernameView

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions