Repository navigation
fix(web): PR Code tab keeps its folds and scroll when you switch right-panel tabs #38761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ddec4ba
cb5a0a9
f7b5e9e
167723a
3d7535a
fdca24c
2388da0
3967266
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -271,6 +271,10 @@ const TABS: ReadonlyArray<{ value: PullRequestDetailTab; label: string }> = [ | |
| const loadCodeTab = () => import("./PullRequestCodeTab"); | ||
| const PullRequestCodeTab = lazy(loadCodeTab); | ||
|
|
||
| // The Code tab restores its scroll on remount; a header left expanded would condense over the | ||
| // restored position and shift it up. | ||
| const codeCondensedByScopeKey = new Map<string, boolean>(); | ||
|
|
||
| function reportCheckoutCommandError(error: Error) { | ||
| toastManager.add({ | ||
| type: "error", | ||
|
|
@@ -539,7 +543,7 @@ export function PullRequestDetailPanel({ | |
| // Each tab restores the condensed state its own scrolling left behind. | ||
| const [condensedByTab, setCondensedByTab] = useState< | ||
| Partial<Record<PullRequestDetailTab, boolean>> | ||
| >({}); | ||
| >(() => ({ code: codeCondensedByScopeKey.get(tabScopeKey) ?? false })); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reset the Code header state when the pull-request scope changes in place.
Reset the Code tab's condensed state when
|
||
| const condensed = condensedByTab[tab] ?? false; | ||
| const scrollerByTab = useRef<Partial<Record<PullRequestDetailTab, HTMLElement | null>>>({}); | ||
| // Fresh ref callbacks would detach and reattach every scroller on each render. | ||
|
|
@@ -2042,7 +2046,9 @@ export function PullRequestDetailPanel({ | |
| compensationRef.current = { tab, scroller, target: top - chromeDelta }; | ||
| next = true; | ||
| } | ||
| if (next !== previous) setCondensedByTab({ ...condensedByTab, [tab]: next }); | ||
| if (next === previous) return; | ||
| if (tab === "code") codeCondensedByScopeKey.set(tabScopeKey, next); | ||
| setCondensedByTab({ ...condensedByTab, [tab]: next }); | ||
| }} | ||
| > | ||
| {detailQuery.error && !detail ? ( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.