Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ function DatePresetFilterBase({
const {translate, dateFnsLocale} = useLocalize();

const shouldShowHorizontalRule = !!presets?.length;
const isCustomDayOnly = allowedCustomDateModifiers.length === 1 && allowedCustomDateModifiers.at(0) === CONST.SEARCH.DATE_MODIFIERS.ON;
const customDateTitle = translate(isCustomDayOnly ? 'search.filters.date.customDay' : 'search.filters.date.customDate');
const customDateTitle = translate('search.filters.date.customDate');
const customRangeTitle = translate('search.filters.date.customRange');
const normalizedDefaultDateValues = useMemo(() => normalizeDateValues(defaultDateValues), [defaultDateValues]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ function DateSelectPopup({label, value, presets, allowedCustomDateModifiers = CO
[value, dateFnsLocale],
);
const displayedRangeText = selectedDateModifier ? rangeText : syncedRangeText;
const isCustomDayOnly = allowedCustomDateModifiers.length === 1 && allowedCustomDateModifiers.at(0) === CONST.SEARCH.DATE_MODIFIERS.ON;
const selectedDateModifierTitle =
isCustomDayOnly && selectedDateModifier === CONST.SEARCH.DATE_MODIFIERS.ON ? translate('search.filters.date.customDay') : getDateModifierTitle(selectedDateModifier, '', translate);
const selectedDateModifierTitle = getDateModifierTitle(selectedDateModifier, '', translate);

const updateRangeText = useCallback(() => {
setRangeText(searchDatePresetFilterBaseRef.current?.getRangeDisplayText() ?? '');
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/DatePresetFilterBaseCustomDateModifiersTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ describe('DatePresetFilterBase allowedCustomDateModifiers', () => {
}
});

it('offers a single-day calendar labelled Custom day when only On is allowed', () => {
it('offers a single-day calendar labelled Custom date when only On is allowed', () => {
// Given the picker as Insights renders it, which only reports on closed periods
const onSelectDateModifier = jest.fn();
renderDatePresetFilterBase({allowedCustomDateModifiers: [CONST.SEARCH.DATE_MODIFIERS.ON], onSelectDateModifier});
expect(screen.queryByText(CUSTOM_DATE)).not.toBeOnTheScreen();
expect(screen.queryByText(CUSTOM_DAY)).not.toBeOnTheScreen();

// When the Custom day option is opened
fireEvent.press(screen.getByText(CUSTOM_DAY), PRESS_EVENT);
// When the Custom date option is opened
fireEvent.press(screen.getByText(CUSTOM_DATE), PRESS_EVENT);

// Then the calendar opens on its own, since there is no modifier left to choose between
expect(onSelectDateModifier).toHaveBeenCalledWith(CONST.SEARCH.DATE_MODIFIERS.ON);
Expand All @@ -122,8 +122,8 @@ describe('DatePresetFilterBase allowedCustomDateModifiers', () => {
onSelectDateModifier,
});

// When the Custom day option is opened
fireEvent.press(screen.getByText(CUSTOM_DAY), PRESS_EVENT);
// When the Custom date option is opened
fireEvent.press(screen.getByText(CUSTOM_DATE), PRESS_EVENT);

// Then the picker switches to On rather than reviving the Before modifier the caller ruled out
expect(onSelectDateModifier).toHaveBeenCalledWith(CONST.SEARCH.DATE_MODIFIERS.ON);
Expand Down
Loading