From 484c218037785d9f67afa8d80390f06952c563d1 Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Mon, 14 Jan 2019 14:37:48 -0800 Subject: [PATCH] Improve the way the URL bar responds to clicks and keypresses --- src/renderer/UrlBar.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/renderer/UrlBar.js b/src/renderer/UrlBar.js index 6cd484f..75d351a 100644 --- a/src/renderer/UrlBar.js +++ b/src/renderer/UrlBar.js @@ -77,16 +77,18 @@ export default class UrlBar extends React.PureComponent { if (inputEl) { inputEl.value = displayedUrl(this.props.url); } - } else { - this.setState({ isEditing: true }); } }; - handleClick = (event: Event) => { + handleChange = (e: Event) => { + this.setState({ isEditing: true }); + }; + + handleFocus = (event: Event) => { const inputEl = this.urlInput; if (!inputEl) return; event.preventDefault(); - inputEl.select(); + setTimeout(() => inputEl.select(), 10); }; handleBlur = (event: Event) => { @@ -106,7 +108,8 @@ export default class UrlBar extends React.PureComponent { "is-primary": this.state.isEditing, })} onKeyDown={this.handleKeyPress} - onClick={this.handleClick} + onChange={this.handleChange} + onFocus={this.handleFocus} onBlur={this.handleBlur} />