Skip to content
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
1 change: 1 addition & 0 deletions src/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,7 @@ export default class Calendar extends Component<CalendarProps, CalendarState> {
})}
showTime={this.props.showTimeSelect || this.props.showTimeInput}
showTimeSelectOnly={this.props.showTimeSelectOnly}
inline={this.props.inline}
>
{this.renderAriaLiveRegion()}
{this.renderPreviousButton()}
Expand Down
6 changes: 4 additions & 2 deletions src/calendar_container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ export interface CalendarContainerProps
extends React.PropsWithChildren<HTMLAttributes<HTMLDivElement>> {
showTimeSelectOnly?: boolean;
showTime?: boolean;
inline?: boolean;
}

const CalendarContainer: React.FC<CalendarContainerProps> = function ({
showTimeSelectOnly = false,
showTime = false,
className,
children,
inline,
}: CalendarContainerProps) {
const ariaLabel = showTimeSelectOnly
? "Choose Time"
Expand All @@ -19,9 +21,9 @@ const CalendarContainer: React.FC<CalendarContainerProps> = function ({
return (
<div
className={className}
role="dialog"
aria-label={ariaLabel}
aria-modal="true"
role={inline ? undefined : "dialog"}
aria-modal={inline ? undefined : "true"}
>
{children}
</div>
Expand Down
20 changes: 19 additions & 1 deletion src/test/calendar_test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2679,7 +2679,7 @@ describe("Calendar", () => {
});

describe("calendar container", () => {
it("should render Calendar with accessibility props", () => {
it("should render Calendar in popover mode with dialog accessibility props", () => {
const { container } = render(
<Calendar
dateFormat={dateFormat}
Expand All @@ -2696,6 +2696,24 @@ describe("Calendar", () => {
expect(dialog?.getAttribute("aria-label")).toBe("Choose Date");
});

it("should render Calendar in inline mode without dialog accessibility props", () => {
const { container } = render(
<Calendar
dateFormat={dateFormat}
onClickOutside={() => {}}
onSelect={() => {}}
dropdownMode="scroll"
inline
/>,
);

const dialog = container.querySelector(".react-datepicker");
expect(dialog).not.toBeNull();
expect(dialog?.getAttribute("role")).toBeNull();
expect(dialog?.getAttribute("aria-modal")).toBeNull();
expect(dialog?.getAttribute("aria-label")).toBe("Choose Date");
});

it("should display corresponding aria-label for Calendar with showTimeSelect", () => {
const { container } = render(
<Calendar
Expand Down
Loading