From 294750afc601fadc7bf2cfc80dbe9f6ee8dce391 Mon Sep 17 00:00:00 2001 From: Cezar Augusto Date: Sat, 20 May 2017 01:01:46 -0300 Subject: [PATCH] make number of tabs match max tabs per page Auditors: @bbondy, @bsclifton Fix #8909 --- js/state/frameStateUtil.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/state/frameStateUtil.js b/js/state/frameStateUtil.js index 4da6782067..19740b70d6 100644 --- a/js/state/frameStateUtil.js +++ b/js/state/frameStateUtil.js @@ -94,6 +94,20 @@ function getFrameKeysByDisplayIndex (state) { }, []) } +function getFrameKeysByNonPinnedDisplayIndex (state) { + return state.get('frames') + .filter((frame) => !frame.get('pinnedLocation')) + .map((frame) => frame.get('key')) +} + + /** + * Obtains the display index for the specified frame key excluding pins + */ +function findNonPinnedDisplayIndexForFrameKey (state, key) { + return getFrameKeysByNonPinnedDisplayIndex(state) + .findIndex((displayKey) => displayKey === key) +} + function getFrameByDisplayIndex (state, i) { let frames = getFrameKeysByDisplayIndex(state) let key = frames[i] @@ -460,7 +474,7 @@ function removeFrame (state, frameProps, activeFrameKey, framePropsIndex, closeA function getFrameTabPageIndex (state, frameProps, tabsPerTabPage) { frameProps = makeImmutable(frameProps) - const index = getFrameIndex(state, frameProps.get('key')) + const index = findNonPinnedDisplayIndexForFrameKey(state, frameProps.get('key')) if (index === -1) { return -1 }