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

Commit

Permalink
Work around for #8974
Browse files Browse the repository at this point in the history
I suspect the root cause is in Muon... specifically a `chrome-tabs-updated` event not firing
when tab.webContent.setActive(true) is called.

Auditors: @bridiver, @NejcZdovc

Test Plan:
See steps in #8974
  • Loading branch information
bsclifton committed May 23, 2017
1 parent 97fb76e commit 3d4bbec
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions app/browser/reducers/tabsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,34 @@ const tabsReducer = (state, action, immutableAction) => {
})
break
case appConstants.APP_TAB_ACTIVATE_REQUESTED:
setImmediate(() => {
tabs.setActive(action.get('tabId'))
})
{
setImmediate(() => {
tabs.setActive(action.get('tabId'))
})

// TODO(bsclifton) - this is a work-around
// which solves https://github.com/brave/browser-laptop/issues/8974
//
// The underlying problem has these steps:
// - tab is cloned two times
// - focus is given to the 2nd cloned tab
// - ctrl + w happens; this triggers APP_TAB_CLOSE_REQUESTED
// - window is closed as expected
// - WINDOW_CLOSE_FRAME is fired + picked up by frameReducer
// - new active frame is picked
// - new frame state is commited to appState
// - APP_TAB_ACTIVATE_REQUESTED is fired (that's this code)
// - APP_FRAME_CHANGED fires (which includes tabState with active = false)
//
// At this point, we're *expecting* APP_TAB_UPDATED
// because it's changed above (`tabs.setActive(action.get('tabId'))`)
// ..but it never happens..

const tab = tabState.getByTabId(state, action.get('tabId'))
if (tab) {
state = tabState.updateTabValue(state, tab.set('active', true))
}
}
break
case appConstants.APP_TAB_INDEX_CHANGED:
setImmediate(() => {
Expand Down

0 comments on commit 3d4bbec

Please sign in to comment.