From 95b8c2f9a12a5afde4f09c9ef2feca8c4638eb12 Mon Sep 17 00:00:00 2001 From: "YUKI \"Piro\" Hiroshi" Date: Wed, 11 Dec 2024 15:15:23 +0900 Subject: [PATCH] Don't show tab preview in the sidebar after the cursor left from the sidebar area --- .../resources/module/tab-preview-frame.js | 2 ++ webextensions/sidebar/tab-preview-tooltip.js | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/webextensions/resources/module/tab-preview-frame.js b/webextensions/resources/module/tab-preview-frame.js index 109604c06..4f90d12cc 100644 --- a/webextensions/resources/module/tab-preview-frame.js +++ b/webextensions/resources/module/tab-preview-frame.js @@ -336,6 +336,8 @@ try{ panel.dataset.tabId != message.previewTabId)) { if (message?.logging) console.log(`hide tab preview(${message.previewTabId}): already hidden, nothing to do `, message.timestamp); + if (!panel && !message.previewTabId) // on initial case + lastTimestamp = message.timestamp; return; } if (message.timestamp < lastTimestamp) { diff --git a/webextensions/sidebar/tab-preview-tooltip.js b/webextensions/sidebar/tab-preview-tooltip.js index eedc46284..00a18e628 100644 --- a/webextensions/sidebar/tab-preview-tooltip.js +++ b/webextensions/sidebar/tab-preview-tooltip.js @@ -405,12 +405,13 @@ async function waitUntilPreviewFrameLoadedIntoTab(tabId) { async function sendInSidebarTabPreviewMessage(message) { + const startAt = message.startAt || Date.now(); log(`sendInSidebarTabPreviewMessage(${message.type}})`); if (typeof message.previewURL == 'function') message.previewURL = await message.previewURL(); await TabPreviewFrame.handleMessage({ + timestamp: startAt, ...message, - timestamp: Date.now(), windowId: TabsStore.getCurrentWindowId(), animation: shouldApplyAnimation(), logging: configs.logFor['sidebar/tab-preview-tooltip'] && configs.debug, @@ -559,17 +560,22 @@ onTabSubstanceLeave = EventUtils.wrapWithErrorHandler(onTabSubstanceLeave); browser.tabs.onActivated.addListener(activeInfo => { + const startAt = Date.now(); + if (activeInfo.windowId != TabsStore.getCurrentWindowId()) return; sendInSidebarTabPreviewMessage({ type: 'treestyletab:hide-tab-preview', + timestamp: startAt, }); sendTabPreviewMessage(activeInfo.tabId, { type: 'treestyletab:hide-tab-preview', + timestamp: startAt, }); sendTabPreviewMessage(activeInfo.previousTabId, { type: 'treestyletab:hide-tab-preview', + timestamp: startAt, }); }); @@ -615,14 +621,19 @@ Sidebar.onReady.addListener(() => { }); document.querySelector('#tabbar').addEventListener('mouseleave', async () => { - log('mouse is left from the tab bar'); + const startAt = Date.now(); + log('mouse is left from the tab bar ', startAt); + + hoveringTabIds.clear(); sendInSidebarTabPreviewMessage({ type: 'treestyletab:hide-tab-preview', + timestamp: startAt, }); const activeTab = Tab.getActiveTab(TabsStore.getCurrentWindowId()); sendTabPreviewMessage(activeTab.id, { type: 'treestyletab:hide-tab-preview', + timestamp: startAt, }); });