Even simpler tab flicker fix (#1421)

This commit is contained in:
Evan Simkowitz 2024-12-06 12:13:49 -08:00 committed by GitHub
parent 925389fc70
commit ab565409cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 13 deletions

View File

@ -43,9 +43,6 @@ function setPlatform(platform: NodeJS.Platform) {
PLATFORM = 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) { function initGlobalAtoms(initOpts: GlobalInitOptions) {
const windowIdAtom = atom(initOpts.windowId) as PrimitiveAtom<string>; const windowIdAtom = atom(initOpts.windowId) as PrimitiveAtom<string>;
const clientIdAtom = atom(initOpts.clientId) as PrimitiveAtom<string>; const clientIdAtom = atom(initOpts.clientId) as PrimitiveAtom<string>;
@ -658,10 +655,6 @@ function createTab() {
} }
function setActiveTab(tabId: string) { function setActiveTab(tabId: string) {
// 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); getApi().setActiveTab(tabId);
} }
@ -688,7 +681,6 @@ export {
isDev, isDev,
loadConnStatus, loadConnStatus,
openLink, openLink,
overrideStaticTabAtom,
PLATFORM, PLATFORM,
pushFlashError, pushFlashError,
pushNotification, pushNotification,

View File

@ -22,7 +22,6 @@ import {
initGlobal, initGlobal,
initGlobalWaveEventSubs, initGlobalWaveEventSubs,
loadConnStatus, loadConnStatus,
overrideStaticTabAtom,
pushFlashError, pushFlashError,
pushNotification, pushNotification,
removeNotificationById, removeNotificationById,
@ -89,16 +88,15 @@ async function reinitWave() {
console.log("Reinit Wave"); console.log("Reinit Wave");
getApi().sendLog("Reinit Wave"); getApi().sendLog("Reinit Wave");
// 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. // We use this hack to prevent a flicker of the previously-hovered tab when this view was last active.
// Also overrides the staticTabAtom to the new tab id so that the active tab is set correctly. document.body.classList.add("nohover");
globalStore.set(overrideStaticTabAtom, savedInitOpts.tabId);
requestAnimationFrame(() => requestAnimationFrame(() =>
setTimeout(() => { setTimeout(() => {
document.body.classList.remove("nohover"); document.body.classList.remove("nohover");
}, 100) }, 100)
); );
const client = await WOS.reloadWaveObject<Client>(WOS.makeORef("client", savedInitOpts.clientId)); await WOS.reloadWaveObject<Client>(WOS.makeORef("client", savedInitOpts.clientId));
const waveWindow = await WOS.reloadWaveObject<WaveWindow>(WOS.makeORef("window", savedInitOpts.windowId)); const waveWindow = await WOS.reloadWaveObject<WaveWindow>(WOS.makeORef("window", savedInitOpts.windowId));
const ws = await WOS.reloadWaveObject<Workspace>(WOS.makeORef("workspace", waveWindow.workspaceid)); const ws = await WOS.reloadWaveObject<Workspace>(WOS.makeORef("workspace", waveWindow.workspaceid));
const initialTab = await WOS.reloadWaveObject<Tab>(WOS.makeORef("tab", savedInitOpts.tabId)); const initialTab = await WOS.reloadWaveObject<Tab>(WOS.makeORef("tab", savedInitOpts.tabId));