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

Commit 4507f5e

Browse files
bbondybridiver
authored andcommitted
Fix pressing esc not restoring location
This fixes a bunch of failing automated tests too. Fix #6148 Auditors: @bsclifton
1 parent 83eef60 commit 4507f5e

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

js/components/navigationBar.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@ class NavigationBar extends ImmutableComponent {
6868
}
6969

7070
onStop () {
71-
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_STOP)
71+
if (this.props.navbar.getIn(['urlbar', 'focused'])) {
72+
windowActions.setUrlBarActive(false)
73+
const shouldRenderSuggestions = this.props.navbar.getIn(['urlbar', 'suggestions', 'shouldRender']) === true
74+
const suggestionList = this.props.navbar.getIn(['urlbar', 'suggestions', 'suggestionList'])
75+
if (!shouldRenderSuggestions ||
76+
// TODO: Once we take out suggestion generation from within URLBarSuggestions we can remove this check
77+
// and put it in shouldRenderUrlBarSuggestions where it belongs. See https://github.com/brave/browser-laptop/issues/3151
78+
!suggestionList || suggestionList.size === 0) {
79+
windowActions.setUrlBarSelected(true)
80+
}
81+
}
7282
}
7383

7484
get bookmarked () {
@@ -190,6 +200,7 @@ class NavigationBar extends ImmutableComponent {
190200
endLoadTime={this.props.endLoadTime}
191201
titleMode={this.titleMode}
192202
urlbar={this.props.navbar.get('urlbar')}
203+
onStop={this.onStop}
193204
menubarVisible={this.props.menubarVisible}
194205
/>
195206
{

js/components/urlBar.js

+1-18
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const {isUrl, isIntermediateAboutPage} = require('../lib/appUrlUtil')
3131
class UrlBar extends ImmutableComponent {
3232
constructor () {
3333
super()
34-
this.onActiveFrameStop = this.onActiveFrameStop.bind(this)
3534
this.onFocus = this.onFocus.bind(this)
3635
this.onBlur = this.onBlur.bind(this)
3736
this.onKeyDown = this.onKeyDown.bind(this)
@@ -213,7 +212,7 @@ class UrlBar extends ImmutableComponent {
213212
break
214213
case KeyCodes.ESC:
215214
e.preventDefault()
216-
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_STOP)
215+
this.props.onStop()
217216
this.clearSearchEngine()
218217
this.restore()
219218
this.select()
@@ -373,28 +372,12 @@ class UrlBar extends ImmutableComponent {
373372
this.detectSearchEngine()
374373
}
375374

376-
onActiveFrameStop () {
377-
if (this.isFocused()) {
378-
windowActions.setUrlBarActive(false)
379-
if (!this.shouldRenderUrlBarSuggestions ||
380-
// TODO: Once we take out suggestion generation from within URLBarSuggestions we can remove this check
381-
// and put it in shouldRenderUrlBarSuggestions where it belongs. See https://github.com/brave/browser-laptop/issues/3151
382-
!this.props.urlbar.getIn(['suggestions', 'suggestionList']) ||
383-
this.props.urlbar.getIn(['suggestions', 'suggestionList']).size === 0) {
384-
this.restore()
385-
windowActions.setUrlBarSelected(true)
386-
}
387-
}
388-
}
389-
390375
componentWillMount () {
391376
ipc.on(messages.SHORTCUT_FOCUS_URL, (e) => {
392377
windowActions.setRenderUrlBarSuggestions(false)
393378
windowActions.setUrlBarSelected(true)
394379
windowActions.setUrlBarActive(true)
395380
})
396-
// escape key handling
397-
ipc.on(messages.SHORTCUT_ACTIVE_FRAME_STOP, this.onActiveFrameStop)
398381
}
399382

400383
componentDidMount () {

0 commit comments

Comments
 (0)