Skip to content

Commit

Permalink
Merge pull request #4549 from qburst/issue-4518/fix/aria-accessibilit…
Browse files Browse the repository at this point in the history
…y-calendar

Fix #4518: 🔨 Add accessibility props like role and aria-modal to the Calendar popup
  • Loading branch information
martijnrusschen authored Feb 29, 2024
2 parents 86ce7a8 + ac6daba commit 705319a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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");
});
});
});

0 comments on commit 705319a

Please sign in to comment.