Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datetimepicker): add check for mask value #3743

Merged
merged 3 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -2817,4 +2817,16 @@ describe('DateTimePickerV2', () => {
expect(onApply).toHaveBeenCalledTimes(1);
});
});

it('should render without a time picker', () => {
render(
<DateTimePicker
{...dateTimePickerProps}
i18n={i18n}
dateTimeMask="MM/DD/YYYY"
hasTimeInput={false}
/>
);
expect(screen.getByText(PRESET_VALUES[0].label)).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ const DateTimePicker = ({
const is24hours = useMemo(() => {
const [, time] = dateTimeMask.split(' ');
const hoursMask = time?.split(':')[0];
return hoursMask.includes('H');
return hoursMask ? hoursMask.includes('H') : false;
}, [dateTimeMask]);
const isSingleSelect = useMemo(() => datePickerType === 'single', [datePickerType]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { iotPrefix } = settings;
const is24hours = (dateTimeMask) => {
const [, time] = dateTimeMask.split(' ');
const hoursMask = time?.split(':')[0];
return hoursMask.includes('H');
return hoursMask ? hoursMask.includes('H') : false;
};

/** convert time from 12 hours to 24 hours, if time12hour is 24 hours format, return immediately
Expand Down