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 #4518: 🔨 Add accessibility props like role and aria-modal to the Calendar popup #4549

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
6 changes: 5 additions & 1 deletion src/calendar_container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import PropTypes from "prop-types";
import React from "react";

export default function CalendarContainer({ className, children }) {
return <div className={className}>{children}</div>;
return (
<div className={className} role="dialog" aria-modal="true">
{children}
</div>
);
}

CalendarContainer.propTypes = {
Expand Down
12 changes: 12 additions & 0 deletions test/calendar_test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Month from "../src/month";
import Day from "../src/day";
import ReactDOM from "react-dom";
import TestUtils from "react-dom/test-utils";
import { render } from "@testing-library/react";
import YearDropdown from "../src/year_dropdown";
import MonthDropdown from "../src/month_dropdown";
import MonthYearDropdown from "../src/month_year_dropdown";
Expand Down Expand Up @@ -1799,4 +1800,15 @@ describe("Calendar", () => {
);
});
});

describe("calendar container", () => {
it("should work", () => {
const { container } = render(<Calendar dateFormat={dateFormat} />);

const dialog = container.querySelector(".react-datepicker");
expect(dialog).not.toBeNull();
expect(dialog.getAttribute("role")).toBe("dialog");
expect(dialog.getAttribute("aria-modal")).toBe("true");
});
});
});
Loading