Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/components/settings/settings-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,24 @@ export function SettingsProvider({
return map;
}, [scopeFieldKeysMap]);

// Track previous loading state to detect when loading finishes.
const [prevLoading, setPrevLoading] = useState(loading);

// Sync internal values when external values change.
// NOTE: Do NOT reset initialValues here — that would break dirty tracking,
// NOTE: Do NOT reset initialValues on every change — that would break dirty tracking,
// because the consumer typically updates externalValues in their onChange handler
// (controlled component pattern). initialValues is captured once on mount
// and only reset after a save via resetPageDirty.
// (controlled component pattern). However, when loading transitions from true→false,
// we re-snapshot initialValues so dirty tracking compares against the real saved data
// (not just schema defaults captured at mount time before async data arrived).
useEffect(() => {
const merged = { ...defaultValues, ...(externalValues || {}) };
setInternalValues(merged);
}, [defaultValues, externalValues]);

if (prevLoading && !loading) {
setInitialValues(merged);
}
setPrevLoading(loading);
}, [defaultValues, externalValues, loading, prevLoading]);

// Auto-select first page/subpage on schema load
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function SheetContent({
showCloseButton?: boolean
}) {
return (
<SheetPortal>
<SheetPortal className="pui-root">
<SheetOverlay />
<SheetPrimitive.Popup
data-slot="sheet-content"
Expand Down
Loading