Skip to content

Commit

Permalink
Don't show tab preview in the sidebar after the cursor left from the
Browse files Browse the repository at this point in the history
sidebar area
  • Loading branch information
piroor committed Dec 11, 2024
1 parent a114fab commit 95b8c2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions webextensions/resources/module/tab-preview-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 13 additions & 2 deletions webextensions/sidebar/tab-preview-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
});
});

Expand Down Expand Up @@ -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,
});
});

0 comments on commit 95b8c2f

Please sign in to comment.