Skip to content
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
19 changes: 19 additions & 0 deletions src/pages/workspace/WorkspaceInviteMessagePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ class WorkspaceInviteMessagePage extends React.Component {
};
}

componentDidMount() {
this.focusTimeout = setTimeout(() => {
Comment thread
hayata-suenaga marked this conversation as resolved.
this.welcomeMessageInputRef.focus();
// Below condition is needed for web, desktop and mweb only, for native cursor is set at end by default.
if (this.welcomeMessageInputRef.value && this.welcomeMessageInputRef.setSelectionRange) {
const length = this.welcomeMessageInputRef.value.length;
this.welcomeMessageInputRef.setSelectionRange(length, length);
}
Comment on lines +84 to +88

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is caused a regression here #20875 (comment).

Why do we need this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is #20875 a regression of this?

On the native the cursor is set at the end of the text, so we want the same behavior for the web and desktop.

}, CONST.ANIMATED_TRANSITION);
}

componentDidUpdate(prevProps) {
if (
!(
Expand All @@ -90,6 +101,13 @@ class WorkspaceInviteMessagePage extends React.Component {
this.setState({welcomeNote: this.getDefaultWelcomeNote()});
}

componentWillUnmount() {
if (!this.focusTimeout) {
return;
}
clearTimeout(this.focusTimeout);
}

getDefaultWelcomeNote() {
return this.props.translate('workspace.inviteMessage.welcomeNote', {
workspaceName: this.props.policy.name,
Expand Down Expand Up @@ -176,6 +194,7 @@ class WorkspaceInviteMessagePage extends React.Component {
</View>
<View style={[styles.mb3]}>
<TextInput
ref={(el) => (this.welcomeMessageInputRef = el)}
inputID="welcomeMessage"
label={this.props.translate('workspace.inviteMessage.personalMessagePrompt')}
autoCompleteType="off"
Expand Down