Skip to content

Commit 3dcfe52

Browse files
committed
fix(ui): eliminate sidebar Filters flash on tab switch
1 parent 4508197 commit 3dcfe52

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/components/issues/IssuesList.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
1+
import React, {
2+
useCallback,
3+
useEffect,
4+
useLayoutEffect,
5+
useMemo,
6+
useState,
7+
} from 'react';
28
import {
39
DebouncedSearchInput,
410
useDebouncedSearchDraft,
@@ -272,8 +278,15 @@ const IssuesList: React.FC<IssuesListProps> = ({
272278
);
273279

274280
const isLargeScreen = useMediaQuery(theme.breakpoints.up('xl'));
275-
const [portalTarget, setPortalTarget] = useState<HTMLElement | null>(null);
276-
useEffect(() => {
281+
// Resolve the sidebar portal target synchronously so a tab switch (which
282+
// remounts this list) renders straight into the sidebar instead of
283+
// flashing the toolbar inline for one frame.
284+
const [portalTarget, setPortalTarget] = useState<HTMLElement | null>(() =>
285+
document.getElementById('tabs-options-portal'),
286+
);
287+
// On the very first page load the portal node is committed after this
288+
// list's first render — pick it up before paint to avoid a flash.
289+
useLayoutEffect(() => {
277290
setPortalTarget(document.getElementById('tabs-options-portal'));
278291
}, []);
279292

0 commit comments

Comments
 (0)