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

Commit

Permalink
Don't remove url suffix when suggestion is selected
Browse files Browse the repository at this point in the history
Fix #11060
  • Loading branch information
bbondy committed Sep 26, 2017
1 parent 37ead60 commit 9079ae5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/renderer/reducers/urlBarReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,11 @@ const urlBarReducer = (state, action) => {
case windowConstants.WINDOW_SET_RENDER_URL_BAR_SUGGESTIONS:
state = setRenderUrlBarSuggestions(state, action.enabled)
break
case windowConstants.WINDOW_ACTIVE_URL_BAR_SUGGESTION_CLICKED:
const selectedIndex = state.getIn(activeFrameStatePath(state).concat(['navbar', 'urlbar', 'suggestions', 'selectedIndex'])) || 0
const suggestionList = state.getIn(activeFrameStatePath(state).concat(['navbar', 'urlbar', 'suggestions', 'suggestionList']))
case windowConstants.WINDOW_ACTIVE_URL_BAR_SUGGESTION_CLICKED: {
const activeFramePath = activeFrameStatePath(state)
const selectedIndex = state.getIn(activeFramePath.concat(['navbar', 'urlbar', 'suggestions', 'selectedIndex'])) || 0
const suggestionList = state.getIn(activeFramePath.concat(['navbar', 'urlbar', 'suggestions', 'suggestionList']))
state = state.setIn(activeFramePath.concat(['navbar', 'urlbar', 'suggestions', 'autocompleteEnabled']), false)
if (suggestionList.size > 0) {
// It's important this doesn't run sync or else the returned state below will overwrite anything done in the click handler
setImmediate(() => {
Expand All @@ -280,6 +282,7 @@ const urlBarReducer = (state, action) => {
})
}
break
}
case windowConstants.WINDOW_ON_STOP:
if (action.isFocused) {
state = setActive(state, false)
Expand Down
5 changes: 5 additions & 0 deletions test/unit/app/renderer/reducers/urlBarReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ describe('urlBarReducer', function () {
urlBarReducer(inputState, {actionType: windowConstants.WINDOW_ACTIVE_URL_BAR_SUGGESTION_CLICKED})
assert.equal(this.suggestionClickHandlers.navigateSiteClickHandler.callCount, 0)
})
it('sets the urlbar to disabled', function () {
const inputState = windowState.setIn(['frames', 1, 'navbar', 'urlbar', 'suggestions', 'suggestionList', Immutable.fromJS([{location: 'https://www.brave.com'}])])
const newState = urlBarReducer(inputState, {actionType: windowConstants.WINDOW_ACTIVE_URL_BAR_SUGGESTION_CLICKED})
assert.equal(newState.getIn(['frames', 1, 'navbar', 'urlbar', 'suggestions', 'autocompleteEnabled']), false)
})
})
})
})

0 comments on commit 9079ae5

Please sign in to comment.