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

Commit

Permalink
Merge pull request #9564 from NejcZdovc/hotfix/#9562-homebutton
Browse files Browse the repository at this point in the history
Fixes middle click not working for  home button
  • Loading branch information
bsclifton committed Jun 19, 2017
1 parent d2597ea commit 24bb638
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app/renderer/components/navigation/navigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class NavigationBar extends React.Component {
this.onReload = this.onReload.bind(this)
this.onHome = this.onHome.bind(this)
this.onReloadLongPress = this.onReloadLongPress.bind(this)
this.auxHomeButtonAdded = false
}

get activeFrame () {
Expand Down Expand Up @@ -117,6 +118,25 @@ class NavigationBar extends React.Component {
componentDidMount () {
ipc.on(messages.SHORTCUT_ACTIVE_FRAME_BOOKMARK, () => this.onToggleBookmark())
ipc.on(messages.SHORTCUT_ACTIVE_FRAME_REMOVE_BOOKMARK, () => this.onToggleBookmark())

if (this.homeButton != null) {
this.homeButton.addEventListener('auxclick', this.onHome)
this.auxHomeButtonAdded = true
}
}

componentWillUpdate () {
if (this.homeButton != null) {
if (this.props.showHomeButton && !this.auxHomeButtonAdded) {
this.homeButton.addEventListener('auxclick', this.onHome)
this.auxHomeButtonAdded = true
}

if (!this.props.showHomeButton && this.auxHomeButtonAdded) {
this.homeButton.removeEventListener('auxclick', this.onHome)
this.auxHomeButtonAdded = false
}
}
}

mergeProps (state, dispatchProps, ownProps) {
Expand Down Expand Up @@ -168,6 +188,7 @@ class NavigationBar extends React.Component {
props.titleMode = titleMode
props.isWideURLbarEnabled = getSetting(settings.WIDE_URL_BAR)
props.activeTabId = activeTabId
props.showHomeButton = !props.titleMode && getSetting(settings.SHOW_HOME_BUTTON)

return props
}
Expand Down Expand Up @@ -208,12 +229,13 @@ class NavigationBar extends React.Component {
</span>
}
{
!this.props.titleMode && getSetting(settings.SHOW_HOME_BUTTON)
this.props.showHomeButton
? <span className='navigationButtonContainer'>
<button
data-test-id='homeButton'
data-l10n-id='homeButton'
className='normalizeButton navigationButton homeButton'
ref={(node) => { this.homeButton = node }}
onClick={this.onHome} />
</span>
: null
Expand Down
12 changes: 12 additions & 0 deletions test/navbar-components/navigationBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,18 @@ describe('navigationBar tests', function () {
.waitForTabCount(2)
.waitForUrl(page2Url)
})

it('opens home page in a new tab when middle mouse button is clicked', function * () {
const page3Url = Brave.server.url('page3.html')

yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.changeSetting(settings.HOMEPAGE, page3Url)
.waitForVisible(homeButton)
.middleClick(homeButton)
.waitForTabCount(3)
.waitForUrl(page3Url)
})
})

describe('when disabled', function () {
Expand Down

0 comments on commit 24bb638

Please sign in to comment.