Skip to content

Commit

Permalink
Making the timezone of the picker more clear to users (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
travjenkins authored Nov 21, 2023
1 parent 83956f9 commit 0203a0e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/components/shared/pickers/DateTimePickerCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { StaticDateTimePicker } from '@mui/x-date-pickers';
import { formatRFC3339 } from 'date-fns';
import { Calendar } from 'iconoir-react';
import { useMemo } from 'react';
import { BaseComponentProps } from 'types';
import { Typography } from '@mui/material';
import { FormattedMessage } from 'react-intl';
import { INVALID_DATE, TIMEZONE_OFFSET_REPLACEMENT } from './shared';
import { PickerProps } from './types';
import DateOrTimePickerWrapper from './DateOrTimePickerWrapper';
Expand All @@ -23,6 +26,24 @@ const formatDate = (formatValue: Date) => {
}
};

function PaperContent({ children }: BaseComponentProps) {
return (
<>
{children}
<Typography
sx={{
textAlign: 'right',
marginRight: 2,
marginBottom: 1,
}}
variant="caption"
>
<FormattedMessage id="dateTimePicker.picker.footer" />
</Typography>
</>
);
}

// TODO (date time picker) weird date formatting issue
// If the user types in a short value (that can be parsed as a date. ex: "1", "12", etc.) If they open the date picker
// and then select the same date that was parsed no change event is fired. This is a weird edge case so not
Expand Down Expand Up @@ -62,6 +83,9 @@ function DateTimePickerCTA(props: PickerProps) {
inputFormat="YYYY-mm-ddTHH:mm:ssZ"
openTo="day"
value={cleanedValue}
components={{
PaperContent,
}}
onAccept={state.close}
onChange={(
onChangeValue: any,
Expand Down
1 change: 1 addition & 0 deletions src/lang/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ const NewTransform: ResolvedIntlConfig['messages'] = {
const CustomRenderers: ResolvedIntlConfig['messages'] = {
'oauth.error.credentialsMissing': `need to complete OAuth`,
'dateTimePicker.button.ariaLabel': `Open date time picker for {label}`,
'dateTimePicker.picker.footer': `Timezone: UTC`,
'datePicker.button.ariaLabel': `Open date picker for {label}`,
'timePicker.button.ariaLabel': `Open time picker for {label}`,
};
Expand Down

0 comments on commit 0203a0e

Please sign in to comment.