mirror of
https://github.com/desktop/desktop
synced 2024-09-19 08:02:22 +00:00
Focus co-author input after clicking on "Add co-authors"
This commit is contained in:
parent
479c6a7609
commit
4021fc138d
|
@ -121,6 +121,8 @@ export class CommitMessage extends React.Component<
|
|||
private descriptionTextArea: HTMLTextAreaElement | null = null
|
||||
private descriptionTextAreaScrollDebounceId: number | null = null
|
||||
|
||||
private coAuthorInputRef = React.createRef<AuthorInput>()
|
||||
|
||||
public constructor(props: ICommitMessageProps) {
|
||||
super(props)
|
||||
const { commitMessage } = this.props
|
||||
|
@ -180,6 +182,14 @@ export class CommitMessage extends React.Component<
|
|||
|
||||
if (this.props.focusCommitMessage) {
|
||||
this.focusSummary()
|
||||
} else if (
|
||||
prevProps.showCoAuthoredBy === false &&
|
||||
this.isCoAuthorInputVisible &&
|
||||
// The co-author input could be also shown when switching between repos,
|
||||
// but in that case we don't want to give the focus to the input.
|
||||
prevProps.repository.id === this.props.repository.id
|
||||
) {
|
||||
this.coAuthorInputRef.current?.focus()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,6 +354,7 @@ export class CommitMessage extends React.Component<
|
|||
|
||||
return (
|
||||
<AuthorInput
|
||||
ref={this.coAuthorInputRef}
|
||||
onAuthorsUpdated={this.onCoAuthorsUpdated}
|
||||
authors={this.props.coAuthors}
|
||||
autoCompleteProvider={autocompletionProvider}
|
||||
|
|
|
@ -467,6 +467,10 @@ export class AuthorInput extends React.Component<IAuthorInputProps, {}> {
|
|||
this.state = {}
|
||||
}
|
||||
|
||||
public focus() {
|
||||
this.editor?.focus()
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
// Sometimes the completion box seems to fail to register
|
||||
// the blur event and close. It's hard to reproduce so
|
||||
|
|
Loading…
Reference in a new issue