From 59673695ac318598c55332b052ad98a20c7b7267 Mon Sep 17 00:00:00 2001 From: Jack <41238731+fisjac@users.noreply.github.com> Date: Mon, 13 May 2024 11:38:12 -0500 Subject: [PATCH] fix(ar-modal): updateNotificationSettings not updating state (#28409) (cherry picked from commit d871b4d267e2e20d337939040d07dc524669ba12) --- .../src/features/alerts/AlertReportModal.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/superset-frontend/src/features/alerts/AlertReportModal.tsx b/superset-frontend/src/features/alerts/AlertReportModal.tsx index 6eb157ab94a24..45e5cbe0a94a8 100644 --- a/superset-frontend/src/features/alerts/AlertReportModal.tsx +++ b/superset-frontend/src/features/alerts/AlertReportModal.tsx @@ -553,13 +553,17 @@ const AlertReportModal: FunctionComponent = ({ index: number, setting: NotificationSetting, ) => { - // if you've changed notification method + const settings: NotificationSetting[] = [...notificationSettings]; + settings[index] = setting; + + // if you've changed notification method -> remove trailing methods if (notificationSettings[index].method !== setting.method) { notificationSettings[index] = setting; setNotificationSettings( notificationSettings.filter((_, idx) => idx <= index), ); + if (notificationSettings.length - 1 > index) { setNotificationAddState('active'); } @@ -567,6 +571,8 @@ const AlertReportModal: FunctionComponent = ({ if (setting.method !== undefined && notificationAddState !== 'hidden') { setNotificationAddState('active'); } + } else { + setNotificationSettings(settings); } };