Skip to content

Commit

Permalink
Fixes tab pages after setting change
Browse files Browse the repository at this point in the history
Resolves brave#7806

Auditors: @bsclifton @cezaraugusto

Test Plan:
- Open about:preferences#tabs
- Set the number of tabs per tab set to 6
- Open new tabs to create a new tab set, which has just 2 tabs
- Increase the number to 8
  • Loading branch information
NejcZdovc committed Jun 29, 2017
1 parent c575303 commit 479a8d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/state/frameStateUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ function isPinned (state, frameKey) {
* Updates the tab page index to the specified frameProps
* @param frameProps Any frame belonging to the page
*/
function updateTabPageIndex (state, frameProps) {
const index = getFrameTabPageIndex(state, frameProps, getSetting(settings.TABS_PER_PAGE))
function updateTabPageIndex (state, frameProps, tabsPerPage = getSetting(settings.TABS_PER_PAGE)) {
const index = getFrameTabPageIndex(state, frameProps, tabsPerPage)

if (index === -1) {
return state
Expand Down
15 changes: 15 additions & 0 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ const frameGuestInstanceIdChanged = (state, action) => {
})
}

function handleChangeSettingAction (state, settingKey, settingValue) {
switch (settingKey) {
case settings.TABS_PER_PAGE:
const activeFrame = frameStateUtil.getActiveFrame(state)
state = frameStateUtil.updateTabPageIndex(state, activeFrame, settingValue)
break
default:
}

return state
}

const windowStore = new WindowStore()
const emitChanges = debounce(windowStore.emitChanges.bind(windowStore), 5)

Expand Down Expand Up @@ -719,6 +731,9 @@ const doAction = (action) => {
}
windowState = newFrame(windowState, action.frameOpts)
break
case appConstants.APP_CHANGE_SETTING:
windowState = handleChangeSettingAction(windowState, action.key, action.value)
break
case windowConstants.WINDOW_FRAME_MOUSE_ENTER:
windowState = windowState.setIn(['ui', 'mouseInFrame'], true)
break
Expand Down

0 comments on commit 479a8d2

Please sign in to comment.