mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(console): discard application settings changes when switching tabs (#5087)
This commit is contained in:
parent
9870ddeff0
commit
a6c1bdb5e4
2 changed files with 7 additions and 3 deletions
|
@ -7,9 +7,10 @@ import ConfirmModal from '@/ds-components/ConfirmModal';
|
|||
type Props = {
|
||||
hasUnsavedChanges: boolean;
|
||||
parentPath?: string;
|
||||
onConfirm?: () => void;
|
||||
};
|
||||
|
||||
function UnsavedChangesAlertModal({ hasUnsavedChanges, parentPath }: Props) {
|
||||
function UnsavedChangesAlertModal({ hasUnsavedChanges, parentPath, onConfirm }: Props) {
|
||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||
const { pathname } = useLocation();
|
||||
const blocker = useBlocker(hasUnsavedChanges);
|
||||
|
@ -36,7 +37,10 @@ function UnsavedChangesAlertModal({ hasUnsavedChanges, parentPath }: Props) {
|
|||
confirmButtonText="general.leave_page"
|
||||
cancelButtonText="general.stay_on_page"
|
||||
onCancel={blocker.reset}
|
||||
onConfirm={blocker.proceed}
|
||||
onConfirm={() => {
|
||||
onConfirm?.();
|
||||
blocker.proceed?.();
|
||||
}}
|
||||
>
|
||||
{t('general.unsaved_changes_warning')}
|
||||
</ConfirmModal>
|
||||
|
|
|
@ -259,7 +259,7 @@ function ApplicationDetails() {
|
|||
</FormProvider>
|
||||
</>
|
||||
)}
|
||||
<UnsavedChangesAlertModal hasUnsavedChanges={!isDeleted && isDirty} />
|
||||
<UnsavedChangesAlertModal hasUnsavedChanges={!isDeleted && isDirty} onConfirm={reset} />
|
||||
</DetailsPage>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue