fixes bugs with LeaveWithoutSaving modal
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 (
|
||||
<NavigationPrompt when={modified}>
|
||||
|
||||
Reference in New Issue
Block a user