diff --git a/src/client/components/forms/useFieldType/index.js b/src/client/components/forms/useFieldType/index.js index 218c108fae..ddbf3e63af 100644 --- a/src/client/components/forms/useFieldType/index.js +++ b/src/client/components/forms/useFieldType/index.js @@ -63,10 +63,12 @@ const useFieldType = (options) => { const setValue = useCallback((e) => { const val = (e && e.target) ? e.target.value : e; - if (!modified) setModified(true); + if (!ignoreWhileFlattening && !modified) { + setModified(true); + } setInternalValue(val); - }, [setModified, modified]); + }, [setModified, modified, ignoreWhileFlattening]); useEffect(() => { setInternalValue(initialValue); diff --git a/src/client/components/modals/LeaveWithoutSaving/index.js b/src/client/components/modals/LeaveWithoutSaving/index.js index 5a693ad179..61c3182043 100644 --- a/src/client/components/modals/LeaveWithoutSaving/index.js +++ b/src/client/components/modals/LeaveWithoutSaving/index.js @@ -1,6 +1,6 @@ import React from 'react'; import NavigationPrompt from 'react-router-navigation-prompt'; -import { useForm } from '../../forms/Form/context'; +import { useFormModified } from '../../forms/Form/context'; import MinimalTemplate from '../../templates/Minimal'; import Button from '../../elements/Button'; @@ -9,7 +9,7 @@ import './index.scss'; const modalSlug = 'leave-without-saving'; const LeaveWithoutSaving = () => { - const { modified } = useForm(); + const modified = useFormModified(); return (