Skip to content

Commit

Permalink
[RAM] Fix broken custom snooze recurrences with monthly frequency (#1…
Browse files Browse the repository at this point in the history
…54251)

## Summary

Fixes #153579

The custom recurrence scheduler improperly expected `byweekday` to never
be `undefined`, which caused it to throw an error when setting custom
recurrences like "Every 2 months on the 4th day of the month."
Recurrences like "Every 2 months on the 1st Tuesday" were working fine
as these had a defined `byweekday`.

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
Zacqary and kibanamachine committed Apr 4, 2023
1 parent bd48d13 commit 73068f1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export const BaseSnoozePanel: React.FunctionComponent<BaseSnoozePanelProps> = ({
style={{
paddingLeft: '9px',
paddingRight: '9px',
height: '36px',
// Replicate euiPanel--accent vs euiPanel--subdued
// Applying these classNames by themselves doesn't work due to a CSS-in-JS issue with EuiPanel
color: isActive ? '#a8376a' : euiTheme.colors.subduedText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const CustomRecurrenceScheduler: React.FC<CustomRecurrenceSchedulerProps>
getInitialByweekday(initialState.byweekday, startDate)
);
const [monthlyRecurDay, setMonthlyRecurDay] = useState(
initialState.freq === RRuleFrequency.MONTHLY && initialState.byweekday.length > 0
initialState.freq === RRuleFrequency.MONTHLY && (initialState.byweekday?.length ?? 0) > 0
? 'weekday'
: 'day'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { i18nFreqSummary, i18nNthWeekdayShort } from './translations';
export interface CustomFrequencyState {
freq: RRuleFrequency;
interval: number;
byweekday: string[];
byweekday?: string[];
bymonthday: number[];
bymonth: number[];
}
Expand All @@ -37,7 +37,7 @@ export const getInitialByweekday = (
(result, n) => ({
...result,
[n]:
initialStateByweekday?.length > 0
initialStateByweekday && initialStateByweekday.length > 0
? initialStateByweekday
// Sanitize nth day strings, e.g. +2MO, -1FR, into just days of the week
.map((w) => w.replace(/[0-9+\-]/g, ''))
Expand Down

0 comments on commit 73068f1

Please sign in to comment.