From f64169385eafad053cfa7e84a6ffa7624a88956d Mon Sep 17 00:00:00 2001 From: Tal Leibman Date: Wed, 1 Jul 2020 19:53:06 +0300 Subject: [PATCH] reset options if freq changes --- src/widgets/RRule.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/widgets/RRule.tsx b/src/widgets/RRule.tsx index acdc41e..066a6cf 100644 --- a/src/widgets/RRule.tsx +++ b/src/widgets/RRule.tsx @@ -120,7 +120,12 @@ interface PropsType { export default function RRule(props: PropsType) { const options = props.rrule; function updateRule(newOptions: Partial): void { - const updatedOptions: RRuleOptions = { ...options, ...newOptions }; + let updatedOptions: RRuleOptions; + if (!!options.freq && !!newOptions.freq && options.freq !== newOptions.freq) { + updatedOptions = { freq: newOptions.freq }; + } else { + updatedOptions = { ...options, ...newOptions } ; + } for (const key of Object.keys(updatedOptions)) { const value = updatedOptions[key];