diff --git a/app/renderer/components/navigation/urlBar.js b/app/renderer/components/navigation/urlBar.js index d23e3c78274..8931f0deaf1 100644 --- a/app/renderer/components/navigation/urlBar.js +++ b/app/renderer/components/navigation/urlBar.js @@ -57,8 +57,7 @@ class UrlBar extends React.Component { if (this.keyPressed || !this.urlInput || this.props.locationValueSuffix.length === 0) { return } - - this.updateAutocomplete(this.lastVal + this.lastSuffix, this.props.locationValue + this.props.locationValueSuffix) + this.updateAutocomplete(this.lastVal, this.props.locationValue + this.props.locationValueSuffix) }, 10) } @@ -232,9 +231,6 @@ class UrlBar extends React.Component { const newSuffix = suggestion.substring(newValue.length) this.setValue(newValue, newSuffix) this.urlInput.setSelectionRange(newValue.length, newValue.length + newSuffix.length + 1) - if (this.suggestionLocation) { - windowActions.setUrlBarSuggestions(undefined, null) - } return true } else { return false @@ -253,11 +249,10 @@ class UrlBar extends React.Component { onChange (e) { if (e.target.value !== this.lastVal + this.lastSuffix) { - this.setValue(e.target.value) - } - - if (this.suggestionLocation) { - windowActions.setUrlBarSuggestions(undefined, null) + if (!this.updateAutocomplete(e.target.value)) { + this.setValue(e.target.value) + } + e.preventDefault() } } @@ -288,11 +283,11 @@ class UrlBar extends React.Component { case KeyCodes.ESC: return } - this.keyPressed = false - windowActions.setNavBarUserInput(this.getValue()) if (this.props.isSelected) { windowActions.setUrlBarSelected(false) } + this.keyPressed = false + windowActions.setNavBarUserInput(this.lastVal) } select () { @@ -347,9 +342,9 @@ class UrlBar extends React.Component { } else if (this.props.location !== prevProps.location) { // This is a url nav change this.setValue(UrlUtil.getDisplayLocation(this.props.location, getSetting(settings.PDFJS_ENABLED))) - } else if (this.props.hasLocationValueSuffix && this.props.isActive && - (this.props.hasLocationValueSuffix !== prevProps.hasLocationValueSuffix || - this.props.urlbarLocation !== prevProps.urlbarLocation)) { + } else if (this.props.hasLocationValueSuffix && + this.props.isActive && + this.props.hasLocationValueSuffix !== this.lastSuffix) { this.showAutocompleteResult() } else if ((this.props.titleMode !== prevProps.titleMode) || (!this.props.isActive && !this.props.isFocused)) { @@ -425,7 +420,7 @@ class UrlBar extends React.Component { const urlbarLocation = urlbar.get('location') const locationValue = (isIntermediateAboutPage(urlbarLocation) && history.size > 0 && !canGoForward) ? history.last() : UrlUtil.getDisplayLocation(urlbarLocation, getSetting(settings.PDFJS_ENABLED)) - const selectedIndex = activeFrame.getIn(['navbar', 'urlbar', 'suggestions', 'selectedIndex']) + const selectedIndex = urlbar.getIn(['suggestions', 'selectedIndex']) const allSiteSettings = siteSettingsState.getAllSiteSettings(state, activeFrame.get('isPrivate')) const braverySettings = siteSettings.getSiteSettingsForURL(allSiteSettings, location) @@ -463,7 +458,7 @@ class UrlBar extends React.Component { props.title = activeFrame.get('title') || '' props.scriptsBlocked = activeFrame.getIn(['noScript', 'blocked']) props.isSecure = activeFrame.getIn(['security', 'isSecure']) - props.hasLocationValueSuffix = activeFrame.getIn(['navbar', 'urlbar', 'suggestions', 'urlSuffix']) + props.hasLocationValueSuffix = urlbar.getIn(['suggestions', 'urlSuffix']) props.startLoadTime = activeFrame.get('startLoadTime') props.endLoadTime = activeFrame.get('endLoadTime') props.loading = activeFrame.get('loading') @@ -475,10 +470,10 @@ class UrlBar extends React.Component { props.onStop = ownProps.onStop props.titleMode = ownProps.titleMode props.locationValue = locationValue - props.locationValueSuffix = activeFrame.getIn(['navbar', 'urlbar', 'suggestions', 'urlSuffix']) + props.locationValueSuffix = urlbar.getIn(['suggestions', 'urlSuffix']) props.selectedIndex = selectedIndex props.suggestionList = urlbar.getIn(['suggestions', 'suggestionList']) - props.suggestion = activeFrame.getIn(['navbar', 'urlbar', 'suggestions', 'suggestionList', selectedIndex - 1]) + props.suggestion = urlbar.getIn(['suggestions', 'suggestionList', selectedIndex - 1]) props.shouldRender = urlbar.getIn(['suggestions', 'shouldRender']) props.urlbarLocation = urlbarLocation props.isActive = urlbar.get('active')