@@ -15,6 +15,7 @@ import {
15
15
systemNotificationTemplatesByGroup ,
16
16
updateNotificationTemplateMethod ,
17
17
} from "api/queries/notifications" ;
18
+ import type { NotificationTemplateMethod } from "api/typesGenerated" ;
18
19
import { Alert } from "components/Alert/Alert" ;
19
20
import { displaySuccess } from "components/GlobalSnackbar/utils" ;
20
21
import { Loader } from "components/Loader/Loader" ;
@@ -26,8 +27,8 @@ import { useDeploySettings } from "../DeploySettingsLayout";
26
27
type MethodToggleGroupProps = {
27
28
templateId : string ;
28
29
value : string ;
29
- available : readonly string [ ] ;
30
- defaultMethod : string ;
30
+ available : readonly NotificationTemplateMethod [ ] ;
31
+ defaultMethod : NotificationTemplateMethod ;
31
32
} ;
32
33
33
34
const MethodToggleGroup : FC < MethodToggleGroupProps > = ( {
@@ -39,7 +40,7 @@ const MethodToggleGroup: FC<MethodToggleGroupProps> = ({
39
40
const updateMethodMutation = useMutation (
40
41
updateNotificationTemplateMethod ( templateId ) ,
41
42
) ;
42
- const options = [ "" , ...available ] ;
43
+ const options : NotificationTemplateMethod [ ] = [ "" , ...available ] ;
43
44
44
45
return (
45
46
< ToggleButtonGroup
@@ -49,6 +50,12 @@ const MethodToggleGroup: FC<MethodToggleGroupProps> = ({
49
50
aria-label = "Notification method"
50
51
css = { styles . toggleGroup }
51
52
onChange = { async ( _ , method ) => {
53
+ // Retain the value if the user clicks the same button, ensuring
54
+ // at least one value remains selected.
55
+ if ( method === value ) {
56
+ return ;
57
+ }
58
+
52
59
await updateMethodMutation . mutateAsync ( {
53
60
method,
54
61
} ) ;
0 commit comments