0
Fork 0
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:
Xiao Yijun 2023-12-11 14:53:12 +08:00 committed by GitHub
parent 9870ddeff0
commit a6c1bdb5e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -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>

View file

@ -259,7 +259,7 @@ function ApplicationDetails() {
</FormProvider>
</>
)}
<UnsavedChangesAlertModal hasUnsavedChanges={!isDeleted && isDirty} />
<UnsavedChangesAlertModal hasUnsavedChanges={!isDeleted && isDirty} onConfirm={reset} />
</DetailsPage>
);
}