Skip to content

Commit

Permalink
Add an option to expose hidden tabs #3495
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Mar 19, 2024
1 parent 6cbe8ae commit 7c000b0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
11 changes: 11 additions & 0 deletions webextensions/common/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -2534,6 +2534,17 @@ Tab.getVisibleTabs = (windowId = null, options = {}) => { // visible, not-collap
});
};

Tab.getHiddenTabs = (windowId = null, options = {}) => {
return TabsStore.queryAll({
windowId,
tabs: TabsStore.getTabsMap(TabsStore.livingTabsInWindow, windowId),
living: true,
ordered: true,
hidden: true,
...options
});
};

Tab.getPinnedTabs = (windowId = null, options = {}) => { // visible, pinned
return TabsStore.queryAll({
windowId,
Expand Down
1 change: 1 addition & 0 deletions webextensions/common/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ export const configs = new Configs({
provressiveHighlightingStep: Number.MAX_SAFE_INTEGER,
progressievHighlightingInterval: 100,
outOfScreenTabsRenderingPages: 1,
renderHiddenTabs: false,
generatedTabElementsPoolLifetimeMsec: 5 * 1000,
undoMultipleTabsClose: true,
allowDragNewTabButton: true,
Expand Down
5 changes: 4 additions & 1 deletion webextensions/common/tabs-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ function matchedWithQuery(tab, query) {
tab.hidden ||
tabStates.has(Constants.kTAB_STATE_SHOWING)))
return false;
if (query.hidden &&
!tab.hidden)
return false;
if (query.controllable &&
(tab.hidden ||
tabStates.has(Constants.kTAB_STATE_SHOWING)))
Expand Down Expand Up @@ -489,7 +492,7 @@ export function updateIndexesForTab(tab) {

export function updateVirtualScrollRenderabilityIndexForTab(tab) {
if (tab.pinned ||
tab.hidden ||
(tab.hidden && !configs.renderHiddenTabs) ||
tab.$TST.states.has(Constants.kTAB_STATE_COLLAPSED_DONE))
removeVirtualScrollRenderableTab(tab);
else
Expand Down
11 changes: 11 additions & 0 deletions webextensions/sidebar/sidebar-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,17 @@ configs.$addObserver(async changedKey => {
case 'labelOverflowStyle':
document.documentElement.setAttribute(Constants.kLABEL_OVERFLOW, configs.labelOverflowStyle);
break;

case 'renderHiddenTabs': {
let hasNormalTab = false;
for (const tab of Tab.getHiddenTabs(TabsStore.getCurrentWindowId(), { iterator: true })) {
TabsStore.updateVirtualScrollRenderabilityIndexForTab(tab);
if (!tab.pinned)
hasNormalTab = true;
}
if (hasNormalTab)
onNormalTabsChanged.dispatch();
}; break;
}
});

Expand Down
4 changes: 1 addition & 3 deletions webextensions/sidebar/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,7 @@ tab-item tab-favicon {
}

tab-item.hidden {
pointer-events: none;
position: fixed;
visibility: collapse;
opacity: 0.6;
}

:root.animation:not(.minimized) tab-item.animation-ready,
Expand Down

0 comments on commit 7c000b0

Please sign in to comment.