From 2c5a36932203d851860edeb8378d5223161afb2e Mon Sep 17 00:00:00 2001 From: yan Date: Thu, 20 Oct 2016 05:16:10 -0400 Subject: [PATCH] prevent urlbar from losing characters fix https://github.com/brave/browser-laptop/issues/4731 Auditors: @bbondy @Sh1d0w Test Plan: 1. open new tab 2. type 'aboutabout' quickly 3. repeat 1 and 2 several times. the urlbar should not lose characters. --- js/components/urlBar.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/components/urlBar.js b/js/components/urlBar.js index 4ec3a72406a..1fa3731a0ca 100644 --- a/js/components/urlBar.js +++ b/js/components/urlBar.js @@ -43,15 +43,16 @@ class UrlBar extends ImmutableComponent { this.onContextMenu = this.onContextMenu.bind(this) this.activateSearchEngine = false this.searchSelectEntry = null + this.keyPressed = false this.showAutocompleteResult = debounce(() => { - if (!this.urlInput) { + if (!this.urlInput || this.keyPressed) { return } const suffixLen = this.props.locationValueSuffix.length this.urlInput.value = this.defaultValue const len = this.defaultValue.length this.urlInput.setSelectionRange(len - suffixLen, len) - }, 300) + }, 100) } get activeFrame () { @@ -197,6 +198,7 @@ class UrlBar extends ImmutableComponent { this.hideAutoComplete() break default: + this.keyPressed = true // Any other keydown is fair game for autocomplete to be enabled. if (!this.autocompleteEnabled) { windowActions.setUrlBarAutocompleteEnabled(true) @@ -267,6 +269,7 @@ class UrlBar extends ImmutableComponent { windowActions.setNavBarUserInput(e.target.value) this.clearSearchEngine() this.detectSearchEngine(e.target.value) + this.keyPressed = false } onFocus (e) {