fix(webui): save settings when editing completes (NAN-323) (#6384)
* fix(webui): save settings when editing completes (NAN-323) * fix(webui): close settings completion and verification gaps * refactor(webui): simplify settings edit ownership
This commit is contained in:
1 parent
26e1f41a00
commit
c6babb20e8
34 files changed
+1363
-388
No files matched your search
@@ -22,7 +22,7 @@ export function SettingsAdvancedOptions({ children }: { children: ReactNode }) {
|
||||
}
|
||||
|
||||
export function SettingsFeature({
|
||||
title, enabled, onChange, disabled, initialOpen = false, error, children,
|
||||
title, enabled, onChange, disabled, initialOpen = false, error, children, onBeforeClose,
|
||||
}: {
|
||||
title: string;
|
||||
enabled: boolean;
|
||||
@@ -31,6 +31,7 @@ export function SettingsFeature({
|
||||
initialOpen?: boolean;
|
||||
error?: string;
|
||||
children?: ReactNode;
|
||||
onBeforeClose?: () => Promise<boolean>;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(initialOpen && enabled);
|
||||
@@ -43,7 +44,11 @@ export function SettingsFeature({
|
||||
}, [initialOpen, enabled]);
|
||||
return (
|
||||
<section ref={section} aria-label={title}>
|
||||
<Dialog open={Boolean(children) && open} onOpenChange={setOpen}>
|
||||
<Dialog open={Boolean(children) && open} onOpenChange={(next) => {
|
||||
if (!next && onBeforeClose) {
|
||||
void onBeforeClose().then((saved) => { if (saved) setOpen(false); });
|
||||
} else setOpen(next);
|
||||
}}>
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={children ? (
|
||||
<DialogTrigger asChild>
|
||||
|
||||
Reference in new issue
Block a user