Clear recurrence options when changing freq.
Apparently iCal.js doesn't filter it itself so we have to do it, otherwise we can create malformed recurrence options. Fixes #134.master
parent
9400abdbf4
commit
64753586e3
|
@ -119,9 +119,14 @@ interface PropsType {
|
|||
|
||||
export default function RRule(props: PropsType) {
|
||||
const options = props.rrule;
|
||||
function updateRule(newOptions: Partial<RRuleOptions>): void {
|
||||
function updateRule(newOptions: Partial<RRuleOptions>, 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}
|
||||
|
|
Loading…
Reference in New Issue