Skip to content

Commit

Permalink
Merge pull request #2400 from decentdao/fix/#2395-unsaved-changes-stu…
Browse files Browse the repository at this point in the history
…ck-state

Fix unsaved changes stuck state
  • Loading branch information
mudrila authored Oct 9, 2024
2 parents 7d19901 + 42d501f commit e91219b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/pages/Roles/forms/RoleFormTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button, Flex, Tab, TabList, TabPanel, TabPanels, Tabs } from '@chakra-u
import { useFormikContext } from 'formik';
import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { Blocker, useNavigate } from 'react-router-dom';
import { Hex } from 'viem';
import { isFeatureEnabled } from '../../../../constants/common';
import { DAO_ROUTES } from '../../../../constants/routes';
Expand All @@ -18,9 +18,11 @@ import { useRoleFormEditedRole } from './useRoleFormEditedRole';
export default function RoleFormTabs({
hatId,
pushRole,
blocker,
}: {
hatId: Hex;
pushRole: (roleHatFormValue: RoleHatFormValue) => void;
blocker: Blocker;
}) {
const { hatsTree } = useRolesStore();
const {
Expand Down Expand Up @@ -99,8 +101,11 @@ export default function RoleFormTabs({
);
}
setFieldValue('roleEditing', undefined);
setTouched({});
if (blocker.reset) {
blocker.reset();
}
setTimeout(() => {
setTouched({});
navigate(DAO_ROUTES.rolesEdit.relative(addressPrefix, daoAddress));
}, 50);
}}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/daos/[daoAddress]/roles/edit/details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export default function RoleEditDetails() {
<RoleFormTabs
hatId={hatEditingId}
pushRole={push}
blocker={blocker}
/>
</Box>
</Box>
Expand Down Expand Up @@ -300,6 +301,7 @@ export default function RoleEditDetails() {
<RoleFormTabs
hatId={hatEditingId}
pushRole={push}
blocker={blocker}
/>
</DrawerBody>
</DrawerContent>
Expand Down
3 changes: 3 additions & 0 deletions src/pages/daos/[daoAddress]/roles/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ function RolesEdit() {
generateRoleProposalTitle({ formValues: values }),
);
}
if (blocker.reset) {
blocker.reset();
}
navigate(
DAO_ROUTES.rolesEditCreateProposalSummary.relative(addressPrefix, daoAddress),
);
Expand Down

0 comments on commit e91219b

Please sign in to comment.