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

Commit

Permalink
Focus not set to active tab/tabset when second tabset is closed Fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Radoslav Vitanov committed Aug 10, 2016
1 parent 316f4ec commit 9317fff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,16 @@ const doAction = (action) => {
case WindowConstants.WINDOW_CLOSE_FRAME:
// Use the frameProps we passed in, or default to the active frame
const frameProps = action.frameProps || FrameStateUtil.getActiveFrame(windowState)
const closingActive = !action.frameProps || action.frameProps === FrameStateUtil.getActiveFrame(windowState)
const index = FrameStateUtil.getFramePropsIndex(windowState.get('frames'), frameProps)
const activeFrameKey = FrameStateUtil.getActiveFrame(windowState).get('key')
windowState = windowState.merge(FrameStateUtil.removeFrame(windowState.get('frames'), windowState.get('tabs'),
windowState.get('closedFrames'), frameProps.set('closedAtIndex', index),
activeFrameKey))
if (closingActive) {
let totalOpenTabs = windowState.get('frames').filter((frame) => !frame.get('pinnedLocation')).size

// If we reach the limit of opened tabs per page while closing tabs, switch to
// the active tab's page otherwise the user will hang on empty page
if ((totalOpenTabs % getSetting(settings.TABS_PER_PAGE)) === 0) {
updateTabPageIndex(FrameStateUtil.getActiveFrame(windowState))
}
break
Expand Down
4 changes: 4 additions & 0 deletions test/components/tabPagesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ describe('tab pages', function () {
})
})

it('focuses active tab\'s page when closing last tab on page', function * () {
yield this.app.client.waitForVisible('.tab.active')
})

describe('allows changing to tab pages', function () {
before(function * () {
// Make sure there are 2 tab pages
Expand Down

0 comments on commit 9317fff

Please sign in to comment.