diff --git a/app/renderer/components/navigation/urlBar.js b/app/renderer/components/navigation/urlBar.js index cc71a93072..3b113af4c5 100644 --- a/app/renderer/components/navigation/urlBar.js +++ b/app/renderer/components/navigation/urlBar.js @@ -192,19 +192,16 @@ class UrlBar extends React.Component { case KeyCodes.TAB: this.hideAutoComplete() break - // Do not trigger rendering of suggestions if you are pressing alt or shift - case KeyCodes.ALT: - case KeyCodes.SHIFT: - case KeyCodes.CMD1: - case KeyCodes.CMD2: - case KeyCodes.CTRL: - break default: this.keyPressed = true - windowActions.setRenderUrlBarSuggestions(true) - // Any other keydown is fair game for autocomplete to be enabled. - if (!this.props.autocompleteEnabled) { - windowActions.urlBarAutocompleteEnabled(true) + // Only enable suggestions and autocomplete if we are typing in + // a printable character without cmd/ctrl + if (e.key && e.key.length === 1 && !e.ctrlKey && !e.metaKey) { + windowActions.setRenderUrlBarSuggestions(true) + // Any other keydown is fair game for autocomplete to be enabled. + if (!this.props.autocompleteEnabled) { + windowActions.urlBarAutocompleteEnabled(true) + } } } } diff --git a/test/lib/brave.js b/test/lib/brave.js index aa9513dcf6..4ae9a9f243 100644 --- a/test/lib/brave.js +++ b/test/lib/brave.js @@ -113,7 +113,8 @@ var exports = { DOWN: '\ue015', UP: '\ue013', PAGEDOWN: '\uE00F', - END: '\uE010' + END: '\uE010', + NULL: '\uE000' }, defaultTimeout: 10000, diff --git a/test/navbar-components/urlBarTest.js b/test/navbar-components/urlBarTest.js index 7e14665d1e..2ed7ccfdfa 100644 --- a/test/navbar-components/urlBarTest.js +++ b/test/navbar-components/urlBarTest.js @@ -1,5 +1,6 @@ /* global describe, it, before, beforeEach */ +const assert = require('assert') const Brave = require('../lib/brave') const {urlInput, urlBarSuggestions, urlbarIcon, reloadButton} = require('../lib/selectors') const searchProviders = require('../../js/data/searchProviders') @@ -183,6 +184,27 @@ describe('urlBar tests', function () { }) }) + describe('press keyboard shortcut', function () { + beforeEach(function * () { + this.page = Brave.server.url('page1.html') + return yield this.app.client + .tabByIndex(0) + .loadUrl(this.page) + .windowByUrl(Brave.browserWindowUrl) + }) + + it('does not show autosuggest', function * () { + return yield this.app.client + .ipcSend('shortcut-focus-url') + .waitForElementFocus(urlInput) + .keys(Brave.keys.CONTROL) + .keys('c') + .keys(Brave.keys.NULL) // needed to release the modifier key + .pause(100) // wait for the suggestions + .isExisting(urlBarSuggestions).then((isExisting) => assert(!isExisting)) + }) + }) + describe('press escape key', function () { beforeEach(function * () { this.page = Brave.server.url('page1.html')