Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofocus the room name field #11587

Merged
merged 3 commits into from
Oct 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class WorkspaceNewRoomPage extends React.Component {
};

this.validateAndAddPolicyReport = this.validateAndAddPolicyReport.bind(this);
this.focusRoomNameInput = this.focusRoomNameInput.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -127,6 +128,14 @@ class WorkspaceNewRoomPage extends React.Component {
}));
}

focusRoomNameInput() {
if (!this.roomNameInputRef) {
return;
}

this.roomNameInputRef.focus();
}

render() {
if (!Permissions.canUsePolicyRooms(this.props.betas)) {
Log.info('Not showing create Policy Room page since user is not on policy rooms beta');
Expand All @@ -141,14 +150,15 @@ class WorkspaceNewRoomPage extends React.Component {
}));

return (
<ScreenWrapper>
<ScreenWrapper onTransitionEnd={this.focusRoomNameInput}>
<HeaderWithCloseButton
title={this.props.translate('newRoomPage.newRoom')}
onCloseButtonPress={() => Navigation.dismissModal()}
/>
<ScrollView style={styles.flex1} contentContainerStyle={styles.p5}>
<View style={styles.mb5}>
<RoomNameInput
ref={el => this.roomNameInputRef = el}
policyID={this.state.policyID}
errorText={this.state.errors.roomName}
onChangeText={roomName => this.clearErrorAndSetValue('roomName', roomName)}
Expand Down