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(DateTimePickerv2): update placeholder text to show XM instead of 'a' or 'A' #3778

Merged
merged 1 commit into from
May 4, 2023
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 @@ -607,8 +607,8 @@ describe('DateTimePickerV2', () => {
}}
/>
);
// default value is YYYY-MM-DD hh:mm A
expect(screen.getByText('YYYY-MM-DD hh:mm A')).toBeVisible();
// default value is YYYY-MM-DD hh:mm XM
expect(screen.getByText('YYYY-MM-DD hh:mm XM')).toBeVisible();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. Why would expect the datetime mask to be XM ? That's not even a valid dayjs mask (at least not as used)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sls-ca Hello Sean, this is an issue reported in Graphite that placeholder texts were inconsistent. Like in the screenshot, time picker follows carbon guideline to use 'XM' as the meridian and date picker uses the time format. User reported it was confusing to see the differences. And 'A' is not as intuitive as 'XM' described in the guideline. To make it consistent, we made sure dateTimePicker use 'XM' in the placeholder text.

image

});

it('should clear date and time fields when click clear button in single select', () => {
Expand Down Expand Up @@ -641,7 +641,7 @@ describe('DateTimePickerV2', () => {

userEvent.click(screen.getByText(/clear/i));

expect(screen.getByText('YYYY-MM-DD hh:mm A')).toBeVisible();
expect(screen.getByText('YYYY-MM-DD hh:mm XM')).toBeVisible();
expect(screen.queryByRole('dialog')).toBeNull();
expect(mockOnClear).toHaveBeenCalledWith({
timeRangeKind: 'SINGLE',
Expand Down Expand Up @@ -685,7 +685,7 @@ describe('DateTimePickerV2', () => {
// first open the menu
userEvent.click(screen.getAllByText(/2020-04-01 12:34 AM/i)[0]);
userEvent.click(screen.getByText(i18n.resetBtnLabel));
expect(screen.getByText('YYYY-MM-DD hh:mm A')).toBeVisible();
expect(screen.getByText('YYYY-MM-DD hh:mm XM')).toBeVisible();

// open the calendar again
userEvent.click(screen.getAllByLabelText('Calendar')[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ export const parseValue = (timeRange, dateTimeMask, toLabel, hasTimeInput) => {
break;
}
case PICKER_KINDS.SINGLE: {
// replace 'a' or 'A' in dateTimeMask to be consistent with time picker placeholder text
const updatedDateTimeMask = dateTimeMask.replace(/a|A/, 'XM');
if (!value.start && !value.startDate) {
readableValue = dateTimeMask;
readableValue = updatedDateTimeMask;
returnValue.single.start = null;
break;
}
Expand All @@ -162,7 +164,7 @@ export const parseValue = (timeRange, dateTimeMask, toLabel, hasTimeInput) => {
startDate = startDate.minutes(formatedStartTime.split(':')[1]);
} else if (hasTimeInput) {
returnValue.absolute.startTime = null;
readableValue = dateTimeMask;
readableValue = updatedDateTimeMask;
break;
}
returnValue.single.start = new Date(startDate.valueOf());
Expand Down