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

Commit

Permalink
prevent urlbar from losing characters
Browse files Browse the repository at this point in the history
fix #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.
  • Loading branch information
diracdeltas committed Oct 20, 2016
1 parent 92b3485 commit 2c5a369
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/components/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2c5a369

Please sign in to comment.