fix(webui): allow closing image settings without valid credentials
Separate capability dialog dismissal from save completion while retaining controller-owned drafts and visible errors. Co-authored-by: QQQ300kuai <934795001@qq.com>
This commit is contained in:
1 parent
34bab234b5
commit
1c66b90088
3 files changed
+61
-17
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, onBeforeClose,
|
||||
title, enabled, onChange, disabled, initialOpen = false, error, children, onClose,
|
||||
}: {
|
||||
title: string;
|
||||
enabled: boolean;
|
||||
@@ -31,7 +31,7 @@ export function SettingsFeature({
|
||||
initialOpen?: boolean;
|
||||
error?: string;
|
||||
children?: ReactNode;
|
||||
onBeforeClose?: () => Promise<boolean>;
|
||||
onClose?: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(initialOpen && enabled);
|
||||
@@ -45,9 +45,8 @@ export function SettingsFeature({
|
||||
return (
|
||||
<section ref={section} aria-label={title}>
|
||||
<Dialog open={Boolean(children) && open} onOpenChange={(next) => {
|
||||
if (!next && onBeforeClose) {
|
||||
void onBeforeClose().then((saved) => { if (saved) setOpen(false); });
|
||||
} else setOpen(next);
|
||||
setOpen(next);
|
||||
if (!next) onClose?.();
|
||||
}}>
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={children ? (
|
||||
|
||||
Reference in new issue
Block a user