-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Auto focus Message input field on workspace invite member page #18791
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,17 @@ class WorkspaceInviteMessagePage extends React.Component { | |
| }; | ||
| } | ||
|
|
||
| componentDidMount() { | ||
| this.focusTimeout = setTimeout(() => { | ||
| 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( | ||
| !( | ||
|
|
@@ -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, | ||
|
|
@@ -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" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.