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

Don't remove url suffix when suggestion is selected #11156

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
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
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)
})
})
})
})