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

Commit

Permalink
Fix pressing esc not restoring location
Browse files Browse the repository at this point in the history
This fixes a bunch of failing automated tests too.

Fix #6148

Auditors: @bsclifton
  • Loading branch information
bbondy committed Dec 12, 2016
1 parent b824ae6 commit 98dfbd1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
13 changes: 12 additions & 1 deletion js/components/navigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,17 @@ class NavigationBar extends ImmutableComponent {
}

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

get bookmarked () {
Expand Down Expand Up @@ -190,6 +200,7 @@ class NavigationBar extends ImmutableComponent {
endLoadTime={this.props.endLoadTime}
titleMode={this.titleMode}
urlbar={this.props.navbar.get('urlbar')}
onStop={this.onStop}
menubarVisible={this.props.menubarVisible}
/>
{
Expand Down
19 changes: 1 addition & 18 deletions js/components/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const {isUrl, isIntermediateAboutPage} = require('../lib/appUrlUtil')
class UrlBar extends ImmutableComponent {
constructor () {
super()
this.onActiveFrameStop = this.onActiveFrameStop.bind(this)
this.onFocus = this.onFocus.bind(this)
this.onBlur = this.onBlur.bind(this)
this.onKeyDown = this.onKeyDown.bind(this)
Expand Down Expand Up @@ -213,7 +212,7 @@ class UrlBar extends ImmutableComponent {
break
case KeyCodes.ESC:
e.preventDefault()
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_STOP)
this.props.onStop()
this.clearSearchEngine()
this.restore()
this.select()
Expand Down Expand Up @@ -373,28 +372,12 @@ class UrlBar extends ImmutableComponent {
this.detectSearchEngine()
}

onActiveFrameStop () {
if (this.isFocused()) {
windowActions.setUrlBarActive(false)
if (!this.shouldRenderUrlBarSuggestions ||
// TODO: Once we take out suggestion generation from within URLBarSuggestions we can remove this check
// and put it in shouldRenderUrlBarSuggestions where it belongs. See https://github.com/brave/browser-laptop/issues/3151
!this.props.urlbar.getIn(['suggestions', 'suggestionList']) ||
this.props.urlbar.getIn(['suggestions', 'suggestionList']).size === 0) {
this.restore()
windowActions.setUrlBarSelected(true)
}
}
}

componentWillMount () {
ipc.on(messages.SHORTCUT_FOCUS_URL, (e) => {
windowActions.setRenderUrlBarSuggestions(false)
windowActions.setUrlBarSelected(true)
windowActions.setUrlBarActive(true)
})
// escape key handling
ipc.on(messages.SHORTCUT_ACTIVE_FRAME_STOP, this.onActiveFrameStop)
}

componentDidMount () {
Expand Down

1 comment on commit 98dfbd1

@bsclifton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.