From 0d4880383c2b481c70552a86ab7eda812207d2ff Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Thu, 18 May 2017 21:38:17 -0400 Subject: [PATCH] Fix URLbar typing fast after newtab getting cleared Fix #8959 Auditors: @bsclifton --- app/renderer/components/navigation/urlBar.js | 6 +++++- test/navbar-components/urlBarTest.js | 22 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/renderer/components/navigation/urlBar.js b/app/renderer/components/navigation/urlBar.js index da2370c124..3e3c8e030b 100644 --- a/app/renderer/components/navigation/urlBar.js +++ b/app/renderer/components/navigation/urlBar.js @@ -389,11 +389,15 @@ class UrlBar extends React.Component { // Each tab has a focused state stored separately if (this.props.isFocused) { this.focus() + this.select() } windowActions.setRenderUrlBarSuggestions(false) } else if (this.props.location !== prevProps.location) { // This is a url nav change - this.setValue(UrlUtil.getDisplayLocation(this.props.location, pdfjsEnabled)) + // This covers the case of user typing fast on newtab when they have lag from lots of bookmarks. + if (!(prevProps.location === 'about:blank' && this.props.location === 'about:newtab' && this.props.locationValue !== 'about:blank')) { + this.setValue(UrlUtil.getDisplayLocation(this.props.location, pdfjsEnabled)) + } } else if (this.props.hasSuggestionMatch && this.props.isActive && this.props.locationValueSuffix !== this.lastSuffix) { diff --git a/test/navbar-components/urlBarTest.js b/test/navbar-components/urlBarTest.js index faea6c3067..a52ac034e1 100644 --- a/test/navbar-components/urlBarTest.js +++ b/test/navbar-components/urlBarTest.js @@ -618,6 +618,28 @@ describe('urlBar tests', function () { }) }) + describe('Typing fast with newtab does not clear user input', function () { + Brave.beforeAll(this) + + before(function * () { + const input = 'brianbondy.com/projects' + yield setup(this.app.client) + yield this.app.client.waitForExist(urlInput) + yield this.app.client.waitForElementFocus(urlInput) + yield this.app.client + .waitForInputText(urlInput, '') + .windowByUrl(Brave.browserWindowUrl) + .newTab() + .waitForElementFocus(urlInput) + .keys(input) + .waitForInputText(urlInput, input) + }) + + it('Retains user input on tab switches', function () { + tabLoadingTest('') + }) + }) + describe('loading same URL as current page with changed input', function () { Brave.beforeAll(this)