From 6ee2c7eafa3a5fe208bf09f3a5a9e06637d58b3b Mon Sep 17 00:00:00 2001 From: Vic Luijkx Date: Thu, 14 Dec 2023 10:46:18 +0100 Subject: [PATCH 1/2] Prevent dirt on saved entry --- resources/js/components/entries/PublishForm.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/js/components/entries/PublishForm.vue b/resources/js/components/entries/PublishForm.vue index 302669bea9..a7d2f6f8eb 100644 --- a/resources/js/components/entries/PublishForm.vue +++ b/resources/js/components/entries/PublishForm.vue @@ -565,7 +565,10 @@ export default { .then(() => { // If revisions are enabled, just emit event. if (this.revisionsEnabled) { + clearTimeout(this.trackDirtyStateTimeout) + this.trackDirtyState = false this.values = this.resetValuesFromResponse(response.data.data.values); + this.trackDirtyStateTimeout = setTimeout(() => (this.trackDirtyState = true), 350) this.$nextTick(() => this.$emit('saved', response)); return; } @@ -586,7 +589,10 @@ export default { // the hooks are resolved because if this form is being shown in a stack, we only // want to close it once everything's done. else { + clearTimeout(this.trackDirtyStateTimeout) + this.trackDirtyState = false this.values = this.resetValuesFromResponse(response.data.data.values); + this.trackDirtyStateTimeout = setTimeout(() => (this.trackDirtyState = true), 350) this.initialPublished = response.data.data.published; this.activeLocalization.published = response.data.data.published; this.activeLocalization.status = response.data.data.status; From a724542ff9747392102d62a4c4ae3745565c024e Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Thu, 14 Dec 2023 17:04:05 +0000 Subject: [PATCH 2/2] tweak to use `$nextTick` instead --- resources/js/components/entries/PublishForm.vue | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/resources/js/components/entries/PublishForm.vue b/resources/js/components/entries/PublishForm.vue index a7d2f6f8eb..a8a4e8ff1f 100644 --- a/resources/js/components/entries/PublishForm.vue +++ b/resources/js/components/entries/PublishForm.vue @@ -565,10 +565,9 @@ export default { .then(() => { // If revisions are enabled, just emit event. if (this.revisionsEnabled) { - clearTimeout(this.trackDirtyStateTimeout) - this.trackDirtyState = false + this.trackDirtyState = false; this.values = this.resetValuesFromResponse(response.data.data.values); - this.trackDirtyStateTimeout = setTimeout(() => (this.trackDirtyState = true), 350) + this.nextTick(() => this.trackDirtyState = true); this.$nextTick(() => this.$emit('saved', response)); return; } @@ -589,10 +588,9 @@ export default { // the hooks are resolved because if this form is being shown in a stack, we only // want to close it once everything's done. else { - clearTimeout(this.trackDirtyStateTimeout) - this.trackDirtyState = false + this.trackDirtyState = false; this.values = this.resetValuesFromResponse(response.data.data.values); - this.trackDirtyStateTimeout = setTimeout(() => (this.trackDirtyState = true), 350) + this.nextTick(() => this.trackDirtyState = true); this.initialPublished = response.data.data.published; this.activeLocalization.published = response.data.data.published; this.activeLocalization.status = response.data.data.status;