perf: move settings subsection scroll cleanup to ref (#4102)

This commit is contained in:
Neil 2026-05-31 04:21:06 -07:00 committed by GitHub
parent 4b1f7b33ac
commit 129b47ca10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 5 deletions

View File

@ -258,6 +258,16 @@ function Settings(): React.JSX.Element {
[setSettingsSearchQuery]
)
const setContentScrollNode = useCallback((node: HTMLDivElement | null): void => {
contentScrollRef.current = node
if (node !== null) {
return
}
// Why: pending subsection jumps are scoped to the scroll container; cancel
// them with the container so a stale deep-link frame cannot run after close.
cancelPendingSettingsSubsectionScrollFrame(pendingSubsectionScrollFrameRef)
}, [])
const confirmDiscardSourceControlAiPromptChanges = useCallback(async (): Promise<boolean> => {
if (!hasUnsavedSourceControlAiPromptChanges) {
return true
@ -605,10 +615,6 @@ function Settings(): React.JSX.Element {
}
}, [neededRepoIds, repos, runtimeTargetIdentity])
useEffect(() => {
return () => cancelPendingSettingsSubsectionScrollFrame(pendingSubsectionScrollFrameRef)
}, [])
useEffect(() => {
const scrollTargetId = pendingScrollTargetRef.current
const pendingNavSectionId = pendingNavSectionRef.current
@ -777,7 +783,7 @@ function Settings(): React.JSX.Element {
<div className="flex min-h-0 flex-1 flex-col">
<div
ref={contentScrollRef}
ref={setContentScrollNode}
className={cn(
'min-h-0 flex-1',
isFocusedShortcutsPane ? 'overflow-hidden' : 'overflow-y-auto scrollbar-sleek'