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

fix syncing between react and DOM urlbar focus/select #5573

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions js/components/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class UrlBar extends ImmutableComponent {
return this.props.urlbar.get('focused')
}

updateDOMInputFocus (focused) {
if (this.urlInput && focused) {
updateDOMInputFocus () {
if (this.urlInput && this.isFocused()) {
this.focus()
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ class UrlBar extends ImmutableComponent {
}
// this can't go through appActions for some reason
// or the whole window will reload on the first page request
this.updateDOMInputFocus(false)
this.updateDOMInputFocus()
this.clearSearchEngine()
}
windowActions.setRenderUrlBarSuggestions(false)
Expand Down Expand Up @@ -371,12 +371,16 @@ class UrlBar extends ImmutableComponent {
}
}
}
// Manually sync some react state with DOM state
if (this.isFocused() !== prevProps.urlbar.get('focused')) {
this.updateDOMInputFocus()
}
if (this.isSelected() !== prevProps.urlbar.get('selected')) {
this.select()
windowActions.setUrlBarSelected(false)
const selected = this.isSelected()
if (selected) {
this.select()
}
windowActions.setUrlBarSelected(selected)
}
}

Expand Down