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

Commit 7f1d0a2

Browse files
committed
URLbar should not remain focused when no back history
Fix #5563 Auditors: @diracdeltas
1 parent 019a910 commit 7f1d0a2

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

js/components/frame.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,11 @@ class Frame extends ImmutableComponent {
10321032
appActions.hideMessageBox(message)
10331033
}
10341034
this.notificationCallbacks = {}
1035-
// only give focus focus is this is not the initial default page load
1036-
if (this.props.isActive && this.webview.canGoBack() && document.activeElement !== this.webview) {
1035+
const isNewTabPage = e.url === getTargetAboutUrl('about:newtab')
1036+
if (isNewTabPage) {
1037+
windowActions.setUrlBarActive(true)
1038+
windowActions.setUrlBarFocused(true)
1039+
} else if (this.props.isActive && !isNewTabPage && document.activeElement !== this.webview) {
10371040
this.webview.focus()
10381041
}
10391042
windowActions.setNavigated(e.url, this.props.frameKey, false, this.frame.get('tabId'))

test/components/navigationBarTest.js

+28
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,34 @@ describe('navigationBar', function () {
5757
}
5858

5959
describe('navigation', function () {
60+
describe('focus', function () {
61+
Brave.beforeAll(this)
62+
before(function * () {
63+
const page1 = Brave.server.url('page1.html')
64+
yield this.app.client.waitForExist(urlInput)
65+
yield this.app.client
66+
.windowByUrl(Brave.browserWindowUrl)
67+
.tabByIndex(0)
68+
.url(page1)
69+
.waitForUrl(page1)
70+
.windowByUrl(Brave.browserWindowUrl)
71+
.ipcSend('shortcut-focus-url')
72+
.waitForElementFocus(urlInput)
73+
.keys(Brave.keys.ENTER)
74+
})
75+
76+
it('webview has focus after initial load', function * () {
77+
yield this.app.client.waitForElementFocus(activeWebview)
78+
})
79+
80+
it('webview has focus after second load', function * () {
81+
yield this.app.client
82+
.ipcSend('shortcut-focus-url')
83+
.waitForElementFocus(urlInput)
84+
.keys(Brave.keys.ENTER)
85+
.waitForElementFocus(activeWebview)
86+
})
87+
})
6088
describe('tabnapping', function () {
6189
Brave.beforeAll(this)
6290

0 commit comments

Comments
 (0)