diff --git a/public/app/features/alerting/components/NotificationChannelForm.tsx b/public/app/features/alerting/components/NotificationChannelForm.tsx index 28b23697838..7820e942b41 100644 --- a/public/app/features/alerting/components/NotificationChannelForm.tsx +++ b/public/app/features/alerting/components/NotificationChannelForm.tsx @@ -36,9 +36,22 @@ export const NotificationChannelForm: FC = ({ }) => { const styles = getStyles(useTheme()); + /* + Finds fields that have dependencies on other fields and removes duplicates. + Needs to be prefixed with settings. + */ + const fieldsToWatch = + new Set( + selectedChannel?.options + .filter(o => o.showWhen.field) + .map(option => { + return `settings.${option.showWhen.field}`; + }) + ) || []; + useEffect(() => { - watch(['type', 'settings.priority', 'sendReminder', 'uploadImage']); - }, []); + watch(['type', 'sendReminder', 'uploadImage', ...fieldsToWatch]); + }, [fieldsToWatch]); const currentFormValues = getValues();