From 4355858a0badfa1c249df78eb1067e0f60b650c8 Mon Sep 17 00:00:00 2001 From: Cezar Augusto Date: Thu, 2 Nov 2017 14:19:09 -0200 Subject: [PATCH] fix bad tab page preview while closing tabs fix #11632 --- js/actions/windowActions.js | 12 ------------ js/state/frameStateUtil.js | 27 +++------------------------ 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/js/actions/windowActions.js b/js/actions/windowActions.js index b3f49b6e667..d6de1b20972 100644 --- a/js/actions/windowActions.js +++ b/js/actions/windowActions.js @@ -273,18 +273,6 @@ const windowActions = { }) }, - /** - * Dispatches a message to the store to set the tab page index being previewed. - * - * @param {number} previewTabPageIndex - The tab page index to preview - */ - setPreviewTabPageIndex: function (previewTabPageIndex) { - dispatch({ - actionType: windowConstants.WINDOW_SET_PREVIEW_TAB_PAGE_INDEX, - previewTabPageIndex - }) - }, - /** * Dispatches a message to the store to set the tab page index. * diff --git a/js/state/frameStateUtil.js b/js/state/frameStateUtil.js index 1b61aab3e14..7072af5ce14 100644 --- a/js/state/frameStateUtil.js +++ b/js/state/frameStateUtil.js @@ -21,7 +21,6 @@ const {getSetting} = require('../settings') const {isIntermediateAboutPage} = require('../lib/appUrlUtil') const urlParse = require('../../app/common/urlParse') -let tabPageHoverTimeout let tabHoverTimeout = null const comparatorByKeyAsc = (a, b) => a.get('key') > b.get('key') @@ -584,36 +583,16 @@ const getPreviewFrameKey = (state) => { return state.get('previewFrameKey') } -const setPreviewTabPageIndex = (state, index, immediate = false) => { - clearTimeout(tabPageHoverTimeout) +const setPreviewTabPageIndex = (state, index) => { const previewTabs = getSetting(settings.SHOW_TAB_PREVIEWS) const isActive = state.getIn(['ui', 'tabs', 'tabPageIndex']) === index + const hoverTabPageIndex = state.getIn(['ui', 'tabs', 'hoverTabPageIndex']) let newTabPageIndex = index - if (!previewTabs || state.getIn(['ui', 'tabs', 'hoverTabPageIndex']) !== index || isActive) { + if (!previewTabs || hoverTabPageIndex !== index || isActive) { newTabPageIndex = null } - if (!immediate) { - // if there is an existing preview tab page index then we're already in preview mode - // we use actions here because that is the only way to delay updating the state - const previewMode = state.getIn(['ui', 'tabs', 'previewTabPageIndex']) != null - if (previewMode && newTabPageIndex == null) { - // add a small delay when we are clearing the preview frame key so we don't lose - // previewMode if the user mouses over another tab - see below - tabPageHoverTimeout = setTimeout(windowActions.setPreviewTabPageIndex.bind(null, null), 200) - return state - } - - if (!previewMode) { - // If user isn't in previewMode so we add a bit of delay to avoid tab from flashing out - // as reported here: https://github.com/brave/browser-laptop/issues/1434 - // using an action here because that is the only way we can do a delayed state update - tabPageHoverTimeout = setTimeout(windowActions.setPreviewTabPageIndex.bind(null, newTabPageIndex), 200) - return state - } - } - return state.setIn(['ui', 'tabs', 'previewTabPageIndex'], newTabPageIndex) }