diff --git a/packages/terra-date-picker/CHANGELOG.md b/packages/terra-date-picker/CHANGELOG.md index 117c7699677..7d7911675d5 100644 --- a/packages/terra-date-picker/CHANGELOG.md +++ b/packages/terra-date-picker/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +* Added + * Added visual focus dashed border for `terra-date-picker`. + * Removed selected date information on focus of picker button. + * Added ariaDescribedBy prop in `terra-date-time-picker` example for invalid error message. + * Changed * Fixed the invalid case for SR announcement. * Changed the SR announcement for changing date from calender. diff --git a/packages/terra-date-picker/src/DateInput.jsx b/packages/terra-date-picker/src/DateInput.jsx index 87be840c8e0..f473302e454 100644 --- a/packages/terra-date-picker/src/DateInput.jsx +++ b/packages/terra-date-picker/src/DateInput.jsx @@ -143,6 +143,12 @@ const propTypes = { * A return value of true will be enabled and false will be disabled. */ filterDate: PropTypes.func, + /** + * ![IMPORTANT](https://badgen.net/badge/UX/Accessibility/blue). + * If invalid error text is used, provide a string containing the IDs for error html element. + * ID must be htmlFor prop value with error text. + */ + errorId: PropTypes.string, }; const defaultProps = { @@ -167,6 +173,7 @@ const defaultProps = { maxDate: '2100-12-31', minDate: '1900-01-01', filterDate: undefined, + errorId: '', }; const DatePickerInput = (props) => { @@ -195,6 +202,7 @@ const DatePickerInput = (props) => { maxDate, minDate, filterDate, + errorId, ...customProps } = props; @@ -717,7 +725,7 @@ const DatePickerInput = (props) => { aria-invalid={isInvalid} aria-required={required} aria-label={`${ariaLabel ? `${ariaLabel} ${intl.formatMessage({ id: 'Terra.datePicker.dayLabel' })}` : intl.formatMessage({ id: 'Terra.datePicker.dayLabel' })}`} - aria-describedby={ariaDescriptionIds} + aria-describedby={`${ariaDescriptionIds} ${errorId}`} id={dayInputId} /> ); @@ -749,7 +757,7 @@ const DatePickerInput = (props) => { aria-invalid={isInvalid} aria-required={required} aria-label={`${ariaLabel ? `${ariaLabel} ${intl.formatMessage({ id: 'Terra.datePicker.monthLabel' })}` : intl.formatMessage({ id: 'Terra.datePicker.monthLabel' })}`} - aria-describedby={ariaDescriptionIds} + aria-describedby={`${ariaDescriptionIds} ${errorId}`} id={monthInputId} /> ); @@ -781,7 +789,7 @@ const DatePickerInput = (props) => { aria-invalid={isInvalid} aria-required={required} aria-label={`${ariaLabel ? `${ariaLabel} ${intl.formatMessage({ id: 'Terra.datePicker.yearLabel' })}` : intl.formatMessage({ id: 'Terra.datePicker.yearLabel' })}`} - aria-describedby={ariaDescriptionIds} + aria-describedby={`${ariaDescriptionIds} ${errorId}`} id={yearInputId} /> ); @@ -808,6 +816,7 @@ const DatePickerInput = (props) => { if (DateUtil.isValidDate(value, momentDateFormat)) { inputDate = `${getLocalizedDateForScreenReader(DateUtil.createSafeDate(dateValue, initialTimeZone), { intl, locale: intl.locale })}`; } + let calendarDate = inputDate ? `${inputDate} ${intl.formatMessage({ id: 'Terra.datePicker.selected' })}` : ''; // Check if date is excluded or out of range or not included or filtered @@ -873,7 +882,7 @@ const DatePickerInput = (props) => { aria-live={DateUtil.isMac() ? 'polite' : 'off'} text={`${invalidEntry} ${intl.formatMessage({ id: 'Terra.datePicker.dateFormatLabel' })} - ${format}. ${inputDate ? `${inputDate},` : ''} ${intl.formatMessage({ id: 'Terra.datePicker.hotKey' })} `} + ${format}. ${inputDate ? `${inputDate},` : ''} ${intl.formatMessage({ id: 'Terra.datePicker.hotKey' })}, `} />