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

Exposed tiles aria-label #763

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 10 additions & 7 deletions src/Calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,14 @@ export default class Calendar extends Component {
const nextActiveStartDate =
// Range selection turned off
!selectRange ||
// Range selection turned on, first value
isFirstValueInRange ||
// Range selection turned on, second value, goToRangeStartOnSelect toggled on
goToRangeStartOnSelect
// Range selection turned on, first value
isFirstValueInRange ||
// Range selection turned on, second value, goToRangeStartOnSelect toggled on
goToRangeStartOnSelect
? getActiveStartDate({
...this.props,
value: nextValue,
})
...this.props,
value: nextValue,
})
: null;

event.persist();
Expand Down Expand Up @@ -461,6 +461,7 @@ export default class Calendar extends Component {
const { activeStartDate: currentActiveStartDate, onMouseOver, valueType, value, view } = this;
const {
calendarType,
tileAriaLabelHandler,
locale,
maxDate,
minDate,
Expand All @@ -484,6 +485,7 @@ export default class Calendar extends Component {
maxDate,
minDate,
onClick,
tileAriaLabelHandler,
onMouseOver: selectRange ? onMouseOver : null,
tileClassName,
tileContent,
Expand Down Expand Up @@ -687,6 +689,7 @@ Calendar.propTypes = {
onDrillDown: PropTypes.func,
onDrillUp: PropTypes.func,
onViewChange: PropTypes.func,
tileAriaLabelHandler: PropTypes.func,
prev2AriaLabel: PropTypes.string,
prev2Label: PropTypes.node,
prevAriaLabel: PropTypes.string,
Expand Down
6 changes: 5 additions & 1 deletion src/Tile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class Tile extends Component {
date,
formatAbbr,
locale,
titleAriaLabelHandler,
maxDate,
maxDateTransform,
minDate,
Expand All @@ -67,6 +68,9 @@ export default class Tile extends Component {
} = this.props;
const { tileClassName, tileContent } = this.state;

const tileAriaLabel = titleAriaLabelHandler ? titleAriaLabelHandler(formatAbbr(locale, date)) : formatAbbr(locale, date)


return (
<button
className={clsx(classes, tileClassName)}
Expand All @@ -81,7 +85,7 @@ export default class Tile extends Component {
style={style}
type="button"
>
{formatAbbr ? <abbr aria-label={formatAbbr(locale, date)}>{children}</abbr> : children}
{formatAbbr ? <abbr aria-label={tileAriaLabel}>{children}</abbr> : children}
{tileContent}
</button>
);
Expand Down
1 change: 1 addition & 0 deletions src/shared/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const tileProps = {
locale: PropTypes.string,
maxDate: isMaxDate,
minDate: isMinDate,
tileAriaLabelHandler: PropTypes.func,
onClick: PropTypes.func,
onMouseOver: PropTypes.func,
style: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
Expand Down