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

Commit

Permalink
autocomplete fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed May 10, 2017
1 parent 19768ea commit 1f95f64
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions app/renderer/components/navigation/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
Expand All @@ -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()
}
}

Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand Down

0 comments on commit 1f95f64

Please sign in to comment.