|
|
@@ -112,6 +112,11 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
|
|
|
: "providers",
|
|
|
)
|
|
|
|
|
|
+ const scrollPositions = useRef<Record<SectionName, number>>(
|
|
|
+ Object.fromEntries(sectionNames.map((s) => [s, 0])) as Record<SectionName, number>,
|
|
|
+ )
|
|
|
+ const contentRef = useRef<HTMLDivElement | null>(null)
|
|
|
+
|
|
|
const prevApiConfigName = useRef(currentApiConfigName)
|
|
|
const confirmDialogHandler = useRef<() => void>()
|
|
|
|
|
|
@@ -398,12 +403,20 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
|
|
|
// Handle tab changes with unsaved changes check
|
|
|
const handleTabChange = useCallback(
|
|
|
(newTab: SectionName) => {
|
|
|
- // Directly switch tab without checking for unsaved changes
|
|
|
+ if (contentRef.current) {
|
|
|
+ scrollPositions.current[activeTab] = contentRef.current.scrollTop
|
|
|
+ }
|
|
|
setActiveTab(newTab)
|
|
|
},
|
|
|
- [], // No dependency on isChangeDetected needed anymore
|
|
|
+ [activeTab],
|
|
|
)
|
|
|
|
|
|
+ useLayoutEffect(() => {
|
|
|
+ if (contentRef.current) {
|
|
|
+ contentRef.current.scrollTop = scrollPositions.current[activeTab] ?? 0
|
|
|
+ }
|
|
|
+ }, [activeTab])
|
|
|
+
|
|
|
// Store direct DOM element refs for each tab
|
|
|
const tabRefs = useRef<Record<SectionName, HTMLButtonElement | null>>(
|
|
|
Object.fromEntries(sectionNames.map((name) => [name, null])) as Record<SectionName, HTMLButtonElement | null>,
|
|
|
@@ -579,7 +592,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
|
|
|
</TabList>
|
|
|
|
|
|
{/* Content area */}
|
|
|
- <TabContent className="p-0 flex-1 overflow-auto">
|
|
|
+ <TabContent ref={contentRef} className="p-0 flex-1 overflow-auto">
|
|
|
{/* Providers Section */}
|
|
|
{activeTab === "providers" && (
|
|
|
<div>
|