Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Highlight input in window.prompt when it is displayed:
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRobinson- committed May 5, 2018
1 parent a2873fa commit 489b1a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/renderer/components/common/messageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class MessageBox extends React.Component {
document.addEventListener('keydown', this.onKeyDown)
}

componentDidMount () {
if (this.props.allowInput) {
this.inputRef.select()
}
}

componentWillUnmount () {
document.removeEventListener('keydown', this.onKeyDown)
}
Expand Down Expand Up @@ -165,6 +171,9 @@ class MessageBox extends React.Component {
this.props.allowInput && (
<PromptTextBox
value={this.state.textInput}
inputRef={ref => {
this.inputRef = ref
}}
onChange={e => {
this.setState({
textInput: e.target.value
Expand Down
4 changes: 3 additions & 1 deletion app/renderer/components/common/textbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ class Textbox extends ImmutableComponent {
)

const props = Object.assign({}, this.props)
const ref = this.props.inputRef
delete props.customClass
delete props.inputRef

return <input type='text' className={className} {...props} />
return <input type='text' className={className} {...props} ref={ref} />
}
}

Expand Down

0 comments on commit 489b1a5

Please sign in to comment.