|
|
@@ -387,9 +387,17 @@ const validate = async function () {
|
|
|
}
|
|
|
|
|
|
// #### Gestion de l'état dirty
|
|
|
-watch(props.modelValue, async (newEntity, oldEntity) => {
|
|
|
- setIsDirty(true)
|
|
|
-})
|
|
|
+watch(
|
|
|
+ // /!\ Important de passer par un getter de l'objet (le `() => ({ ...props.modelValue })`),
|
|
|
+ // car on perd la réactivité de celui-ci quand on soumet le formulaire
|
|
|
+ // (et donc le watcher cesse de fonctionner)
|
|
|
+ () => ({ ...props.modelValue }),
|
|
|
+ (newEntity, oldEntity) => {
|
|
|
+ if (JSON.stringify(newEntity) !== JSON.stringify(oldEntity)) {
|
|
|
+ setIsDirty(true)
|
|
|
+ }
|
|
|
+ },
|
|
|
+)
|
|
|
|
|
|
/**
|
|
|
* Handle events if the form is dirty to prevent submission
|