From 829e4323e93505e28c37a9e06194701c943f5e30 Mon Sep 17 00:00:00 2001
From: Petr Stribny <petr@stribny.name>
Date: Wed, 12 Mar 2025 07:53:12 +0100
Subject: [PATCH] Add optimistic update when deleting chart series

---
 .../data_source/GroupedAggregateRowsDataSourceForm.vue   | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/GroupedAggregateRowsDataSourceForm.vue b/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/GroupedAggregateRowsDataSourceForm.vue
index 8bad8fe41..75799741d 100644
--- a/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/GroupedAggregateRowsDataSourceForm.vue
+++ b/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/GroupedAggregateRowsDataSourceForm.vue
@@ -83,6 +83,7 @@
       <div class="margin-bottom-2"></div>
       <AggregationSeriesForm
         v-for="(series, index) in values.aggregation_series"
+        ref="aggregationSeriesForms"
         :key="index"
         :table-fields="tableFields"
         :aggregation-series="values.aggregation_series"
@@ -346,13 +347,15 @@ export default {
     },
     async deleteSeries(index) {
       this.setEmitValues(false)
-      const updatedAggregationSeries = this.values.aggregation_series
-      updatedAggregationSeries.splice(index, 1)
+      this.values.aggregation_series.splice(index, 1)
+      await this.$nextTick()
+      this.$refs.aggregationSeriesForms.forEach((form) => form.reset())
       this.$emit('values-changed', {
-        aggregation_series: updatedAggregationSeries,
+        aggregation_series: this.values.aggregation_series,
       })
       await this.$nextTick()
       this.setEmitValues(true)
+      this.v$.$touch()
     },
     onAggregationSeriesUpdated(index, aggregationSeriesValues) {
       const updatedAggregationSeries = this.values.aggregation_series