diff --git a/src/widgets/RRule.tsx b/src/widgets/RRule.tsx index acdc41e..64cbe4f 100644 --- a/src/widgets/RRule.tsx +++ b/src/widgets/RRule.tsx @@ -119,9 +119,14 @@ interface PropsType { export default function RRule(props: PropsType) { const options = props.rrule; - function updateRule(newOptions: Partial): void { + function updateRule(newOptions: Partial, reset = false): void { const updatedOptions: RRuleOptions = { ...options, ...newOptions }; + if (reset) { + props.onChange(updatedOptions); + return; + } + for (const key of Object.keys(updatedOptions)) { const value = updatedOptions[key]; if ((value === undefined) || (value?.length === 0)) { @@ -149,7 +154,7 @@ export default function RRule(props: PropsType) { style={{ marginLeft: '0.5em' }} onChange={(event: React.FormEvent<{ value: unknown }>) => { const freq = (event.target as HTMLSelectElement).value as ICAL.FrequencyValues; - updateRule({ freq: freq }); + updateRule({ freq: freq }, true); }} > {menuItemsFrequency}