fix: use nullish coalescing for recurrence weekday to allow Sunday selection (#1014)
Fixes #812 When creating a "Monthly on weekday" recurring task, the selector would jump back to Monday when trying to select Sunday. This was caused by using the logical OR operator (||) instead of the nullish coalescing operator (??) when handling the recurrence_weekday value. Since Sunday is represented as 0, the || operator treated it as falsy and defaulted to null/undefined, which then defaulted to 1 (Monday). Changes: - Replace || with ?? for recurrence_weekday in TaskRecurrenceCard.tsx - Replace || with ?? for recurrence_weekday in TaskDetails.tsx - Also fix recurrence_week_of_month and recurrence_month_day for consistency
This commit is contained in:
parent
372716947a
commit
733b6cd14b
2 changed files with 18 additions and 18 deletions
|
|
@ -140,10 +140,10 @@ const TaskDetails: React.FC = () => {
|
|||
recurrence_type: task?.recurrence_type || 'none',
|
||||
recurrence_interval: task?.recurrence_interval || 1,
|
||||
recurrence_end_date: task?.recurrence_end_date || '',
|
||||
recurrence_weekday: task?.recurrence_weekday || null,
|
||||
recurrence_weekday: task?.recurrence_weekday ?? null,
|
||||
recurrence_weekdays: task?.recurrence_weekdays || [],
|
||||
recurrence_month_day: task?.recurrence_month_day || null,
|
||||
recurrence_week_of_month: task?.recurrence_week_of_month || null,
|
||||
recurrence_month_day: task?.recurrence_month_day ?? null,
|
||||
recurrence_week_of_month: task?.recurrence_week_of_month ?? null,
|
||||
completion_based: task?.completion_based || false,
|
||||
});
|
||||
const [activePill, setActivePill] = useState('overview');
|
||||
|
|
@ -159,10 +159,10 @@ const TaskDetails: React.FC = () => {
|
|||
recurrence_type: task?.recurrence_type || 'none',
|
||||
recurrence_interval: task?.recurrence_interval || 1,
|
||||
recurrence_end_date: task?.recurrence_end_date || '',
|
||||
recurrence_weekday: task?.recurrence_weekday || null,
|
||||
recurrence_weekday: task?.recurrence_weekday ?? null,
|
||||
recurrence_weekdays: task?.recurrence_weekdays || [],
|
||||
recurrence_month_day: task?.recurrence_month_day || null,
|
||||
recurrence_week_of_month: task?.recurrence_week_of_month || null,
|
||||
recurrence_month_day: task?.recurrence_month_day ?? null,
|
||||
recurrence_week_of_month: task?.recurrence_week_of_month ?? null,
|
||||
completion_based: task?.completion_based || false,
|
||||
});
|
||||
}, [
|
||||
|
|
@ -187,10 +187,10 @@ const TaskDetails: React.FC = () => {
|
|||
recurrence_type: task?.recurrence_type || 'none',
|
||||
recurrence_interval: task?.recurrence_interval || 1,
|
||||
recurrence_end_date: task?.recurrence_end_date || '',
|
||||
recurrence_weekday: task?.recurrence_weekday || null,
|
||||
recurrence_weekday: task?.recurrence_weekday ?? null,
|
||||
recurrence_weekdays: task?.recurrence_weekdays || [],
|
||||
recurrence_month_day: task?.recurrence_month_day || null,
|
||||
recurrence_week_of_month: task?.recurrence_week_of_month || null,
|
||||
recurrence_month_day: task?.recurrence_month_day ?? null,
|
||||
recurrence_week_of_month: task?.recurrence_week_of_month ?? null,
|
||||
completion_based: task?.completion_based || false,
|
||||
});
|
||||
setIsEditingRecurrence(true);
|
||||
|
|
@ -247,7 +247,7 @@ const TaskDetails: React.FC = () => {
|
|||
recurrence_weekday:
|
||||
recurrenceForm.recurrence_type === 'weekly' ||
|
||||
recurrenceForm.recurrence_type === 'monthly_weekday'
|
||||
? recurrenceForm.recurrence_weekday || null
|
||||
? recurrenceForm.recurrence_weekday ?? null
|
||||
: null,
|
||||
recurrence_weekdays:
|
||||
recurrenceForm.recurrence_type === 'weekly'
|
||||
|
|
@ -255,11 +255,11 @@ const TaskDetails: React.FC = () => {
|
|||
: null,
|
||||
recurrence_month_day:
|
||||
recurrenceForm.recurrence_type === 'monthly'
|
||||
? recurrenceForm.recurrence_month_day || null
|
||||
? recurrenceForm.recurrence_month_day ?? null
|
||||
: null,
|
||||
recurrence_week_of_month:
|
||||
recurrenceForm.recurrence_type === 'monthly_weekday'
|
||||
? recurrenceForm.recurrence_week_of_month || null
|
||||
? recurrenceForm.recurrence_week_of_month ?? null
|
||||
: null,
|
||||
completion_based: recurrenceForm.completion_based,
|
||||
};
|
||||
|
|
@ -298,10 +298,10 @@ const TaskDetails: React.FC = () => {
|
|||
recurrence_type: task?.recurrence_type || 'none',
|
||||
recurrence_interval: task?.recurrence_interval || 1,
|
||||
recurrence_end_date: task?.recurrence_end_date || '',
|
||||
recurrence_weekday: task?.recurrence_weekday || null,
|
||||
recurrence_weekday: task?.recurrence_weekday ?? null,
|
||||
recurrence_weekdays: task?.recurrence_weekdays || [],
|
||||
recurrence_month_day: task?.recurrence_month_day || null,
|
||||
recurrence_week_of_month: task?.recurrence_week_of_month || null,
|
||||
recurrence_month_day: task?.recurrence_month_day ?? null,
|
||||
recurrence_week_of_month: task?.recurrence_week_of_month ?? null,
|
||||
completion_based: task?.completion_based || false,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -150,16 +150,16 @@ const TaskRecurrenceCard: React.FC<TaskRecurrenceCardProps> = ({
|
|||
recurrenceForm.recurrence_end_date || undefined
|
||||
}
|
||||
recurrenceWeekday={
|
||||
recurrenceForm.recurrence_weekday || undefined
|
||||
recurrenceForm.recurrence_weekday ?? undefined
|
||||
}
|
||||
recurrenceWeekdays={
|
||||
recurrenceForm.recurrence_weekdays || []
|
||||
}
|
||||
recurrenceMonthDay={
|
||||
recurrenceForm.recurrence_month_day || undefined
|
||||
recurrenceForm.recurrence_month_day ?? undefined
|
||||
}
|
||||
recurrenceWeekOfMonth={
|
||||
recurrenceForm.recurrence_week_of_month ||
|
||||
recurrenceForm.recurrence_week_of_month ??
|
||||
undefined
|
||||
}
|
||||
completionBased={recurrenceForm.completion_based}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue