Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions frontend/app/store/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ function setPlatform(platform: NodeJS.Platform) {
PLATFORM = platform;
}

// Used to override the tab id when switching tabs to prevent flicker in the tab bar.
const overrideStaticTabAtom = atom(null) as PrimitiveAtom<string>;

function initGlobalAtoms(initOpts: GlobalInitOptions) {
const windowIdAtom = atom(initOpts.windowId) as PrimitiveAtom<string>;
const clientIdAtom = atom(initOpts.clientId) as PrimitiveAtom<string>;
Expand Down Expand Up @@ -100,9 +103,8 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
const tabAtom: Atom<Tab> = atom((get) => {
return WOS.getObjectValue(WOS.makeORef("tab", initOpts.tabId), get);
});
const staticTabIdAtom: Atom<string> = atom((get) => {
return initOpts.tabId;
});
// This atom is used to determine the tab id to use for the static tab. It is set to the overrideStaticTabAtom value if it is not null, otherwise it is set to the initOpts.tabId value.
const staticTabIdAtom: Atom<string> = atom((get) => get(overrideStaticTabAtom) ?? initOpts.tabId);
const controlShiftDelayAtom = atom(false);
const updaterStatusAtom = atom<UpdaterStatus>("up-to-date") as PrimitiveAtom<UpdaterStatus>;
try {
Expand Down Expand Up @@ -625,7 +627,9 @@ function createTab() {
}

function setActiveTab(tabId: string) {
// We use this hack to prevent a flicker in the tab bar when switching to a new tab. This class is unset in reinitWave in wave.ts. See tab.scss for where this class is used.
// We use this hack to prevent a flicker of the previously-hovered tab when this view was last active. This class is set in setActiveTab in global.ts. See tab.scss for where this class is used.
// Also overrides the staticTabAtom to the new tab id so that the active tab is set correctly.
globalStore.set(overrideStaticTabAtom, tabId);
document.body.classList.add("nohover");
getApi().setActiveTab(tabId);
}
Expand Down Expand Up @@ -653,6 +657,7 @@ export {
isDev,
loadConnStatus,
openLink,
overrideStaticTabAtom,
PLATFORM,
pushFlashError,
pushNotification,
Expand Down
6 changes: 6 additions & 0 deletions frontend/app/tab/tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
}
}

// Only apply hover effects when not in nohover mode. This prevents the previously-hovered tab from remaining hovered while a tab view is not mounted.
body:not(.nohover) .tab:hover {
& + .tab::after,
&::after {
Expand All @@ -120,6 +121,11 @@ body:not(.nohover) .tab:hover {
}
}

// When in nohover mode, always show the close button on the active tab. This prevents the close button of the active tab from flickering when nohover is toggled.
body.nohover .tab.active .close {
visibility: visible;
}

@keyframes expandWidthAndFadeIn {
from {
width: var(--initial-tab-width);
Expand Down
13 changes: 7 additions & 6 deletions frontend/wave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
initGlobal,
initGlobalWaveEventSubs,
loadConnStatus,
overrideStaticTabAtom,
pushFlashError,
pushNotification,
removeNotificationById,
Expand Down Expand Up @@ -88,12 +89,12 @@ async function reinitWave() {
console.log("Reinit Wave");
getApi().sendLog("Reinit Wave");

// We use this hack to prevent a flicker in the tab bar when switching to a new tab. This class is set in setActiveTab in global.ts. See tab.scss for where this class is used.
requestAnimationFrame(() => {
setTimeout(() => {
document.body.classList.remove("nohover");
}, 100);
});
// We use this hack to prevent a flicker of the previously-hovered tab when this view was last active. This class is set in setActiveTab in global.ts. See tab.scss for where this class is used.
// Also overrides the staticTabAtom to the new tab id so that the active tab is set correctly.
globalStore.set(overrideStaticTabAtom, savedInitOpts.tabId);
setTimeout(() => {
document.body.classList.remove("nohover");
}, 100);

const client = await WOS.reloadWaveObject<Client>(WOS.makeORef("client", savedInitOpts.clientId));
const waveWindow = await WOS.reloadWaveObject<WaveWindow>(WOS.makeORef("window", savedInitOpts.windowId));
Expand Down