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

Commit 84e1abc

Browse files
committed
Merge pull request #9618 from brave/9561
Show right number of tabs when closing with mouse on first tab in new…
1 parent dbca71a commit 84e1abc

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

js/stores/windowStore.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,8 @@ const doAction = (action) => {
687687
}
688688
break
689689
case windowConstants.WINDOW_TAB_CLOSED_WITH_MOUSE:
690-
if (frameStateUtil.getNonPinnedFrameCount(windowState) % getSetting(settings.TABS_PER_PAGE) === 0) {
690+
const frameCountAfterClose = frameStateUtil.getNonPinnedFrameCount(windowState) - 1
691+
if (frameCountAfterClose % getSetting(settings.TABS_PER_PAGE) === 0) {
691692
windowState = windowState.deleteIn(['ui', 'tabs', 'fixTabWidth'])
692693
} else {
693694
windowState = windowState.setIn(['ui', 'tabs', 'fixTabWidth'], action.data.fixTabWidth)

test/lib/brave.js

+7
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,13 @@ var exports = {
535535
})
536536
})
537537

538+
this.app.client.addCommand('closeTabWithMouse', function () {
539+
logVerbose('closeTabWithMouse()')
540+
return this.execute(function () {
541+
return devTools('electron').testData.windowActions.onTabClosedWithMouse()
542+
})
543+
})
544+
538545
this.app.client.addCommand('waitForInputText', function (selector, input) {
539546
logVerbose('waitForInputText("' + selector + '", "' + input + '")')
540547
return this

test/tab-components/tabPagesTest.js

+12
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ describe('tab pages', function () {
5555
yield this.app.client.waitForVisible('[data-test-active-tab]')
5656
})
5757

58+
it('shows the right number of tabs after closing with mouse', function * () {
59+
const numTabsPerPage = appConfig.defaultSettings[settings.TABS_PER_PAGE]
60+
const firstTabOfNewPageIndex = numTabsPerPage
61+
yield this.app.client.click(newFrameButton)
62+
.waitForElementCount(tabPage, 2)
63+
.closeTabWithMouse()
64+
.closeTabByIndex(firstTabOfNewPageIndex)
65+
// No tab page indicator elements when 1 page
66+
.waitForElementCount(tabPage, 0)
67+
.waitForElementCount(tabsTabs, numTabsPerPage)
68+
})
69+
5870
describe('allows changing to tab pages', function () {
5971
beforeEach(function * () {
6072
// Make sure there are 2 tab pages

0 commit comments

Comments
 (0)