diff --git a/src/DataTable/filters/CheckboxFilter.jsx b/src/DataTable/filters/CheckboxFilter.jsx index 83780665b2..379666d26a 100644 --- a/src/DataTable/filters/CheckboxFilter.jsx +++ b/src/DataTable/filters/CheckboxFilter.jsx @@ -2,8 +2,8 @@ import React, { useRef, useMemo } from 'react'; import PropTypes from 'prop-types'; import Form, { FormLabel } from '../../Form'; import Badge from '../../Badge'; +import Stack from '../../Stack'; import { newId } from '../../utils'; -import LabelledCheckbox from './LabelledCheckbox'; function CheckboxFilter({ column: { @@ -27,15 +27,21 @@ function CheckboxFilter({ return ( {Header} - {filterChoices.map(({ name, number, value }) => ( - { changeCheckbox(value); }} - label={<>{name} {number !== undefined && {number}}} - /> - ))} + + {filterChoices.map(({ name, number, value }) => ( + changeCheckbox(value)} + aria-label={name} + > + + {name} {number !== undefined && {number}} + + + ))} + ); } diff --git a/src/DataTable/filters/LabelledCheckbox.jsx b/src/DataTable/filters/LabelledCheckbox.jsx deleted file mode 100644 index 64e217d261..0000000000 --- a/src/DataTable/filters/LabelledCheckbox.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import React, { useRef } from 'react'; -import PropTypes from 'prop-types'; -import Form from '../../Form'; -import { newId } from '../../utils'; - -function LabelledCheckbox({ - onChange, checked, label, id, -}) { - const idRef = useRef(newId(id)); - return ( -
- -
- ); -} - -LabelledCheckbox.propTypes = { - checked: PropTypes.bool.isRequired, - onChange: PropTypes.func.isRequired, - label: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired, - id: PropTypes.string.isRequired, -}; - -export default LabelledCheckbox; diff --git a/src/DataTable/filters/MultiSelectDropdownFilter.jsx b/src/DataTable/filters/MultiSelectDropdownFilter.jsx index 39458c5014..3ffd98d62c 100644 --- a/src/DataTable/filters/MultiSelectDropdownFilter.jsx +++ b/src/DataTable/filters/MultiSelectDropdownFilter.jsx @@ -1,9 +1,10 @@ -import React, { useRef, useMemo } from 'react'; +import React, { useRef } from 'react'; import PropTypes from 'prop-types'; import Badge from '../../Badge'; +import Stack from '../../Stack'; import { DropdownButton } from '../../Dropdown'; import { newId } from '../../utils'; -import LabelledCheckbox from './LabelledCheckbox'; +import Form from '../../Form'; function MultiSelectDropdownFilter({ column: { @@ -21,20 +22,28 @@ function MultiSelectDropdownFilter({ checkedBoxes.push(value); return setFilter(checkedBoxes); }; - const headerBasedId = useMemo(() => `checkbox-filter-check-${getHeaderProps().key}-`, [getHeaderProps]); + return ( -
+ {filterChoices.map(({ name, number, value }) => ( - { changeCheckbox(value); }} - label={<>{name} {number && {number}}} - /> + onChange={() => changeCheckbox(value)} + aria-label={name} + > + + {name} {number && {number}} + + ))} -
+
); } diff --git a/src/DataTable/filters/tests/CheckboxFilter.test.jsx b/src/DataTable/filters/tests/CheckboxFilter.test.jsx index 9281bbe7ed..50b3d01c70 100644 --- a/src/DataTable/filters/tests/CheckboxFilter.test.jsx +++ b/src/DataTable/filters/tests/CheckboxFilter.test.jsx @@ -54,19 +54,19 @@ describe('', () => { }); it('renders checkbox label with filter name', () => { const wrapper = mount(); - const label = wrapper.find('.form-check-label').at(0); + const label = wrapper.find('.pgn__form-checkbox').at(0); expect(label.text()).toContain(roan.name); }); it('renders checkbox label with number', () => { const wrapper = mount(); - const label = wrapper.find('.pgn__checkbox-filter').at(0); + const label = wrapper.find('.pgn__form-checkbox').at(0); const badge = label.find(Badge); expect(badge).toHaveLength(1); expect(badge.text()).toEqual(String(roan.number)); }); it('renders checkbox label with number', () => { const wrapper = mount(); - const label = wrapper.find('.pgn__checkbox-filter').at(1); + const label = wrapper.find('.pgn__form-checkbox').at(1); const badge = label.find(Badge); expect(badge).toHaveLength(0); }); diff --git a/src/DataTable/filters/tests/MultiSelectDropdownFilter.test.jsx b/src/DataTable/filters/tests/MultiSelectDropdownFilter.test.jsx index 1ced27ddfd..c8aa7e7b9c 100644 --- a/src/DataTable/filters/tests/MultiSelectDropdownFilter.test.jsx +++ b/src/DataTable/filters/tests/MultiSelectDropdownFilter.test.jsx @@ -69,7 +69,7 @@ describe('', () => { const wrapper = mount(); wrapper.find('button').simulate('click'); await act(async () => { - const label = wrapper.find('.form-check-label').at(0); + const label = wrapper.find('.pgn__form-label').at(0); expect(label.text()).toContain(roan.name); }); }); @@ -78,7 +78,7 @@ describe('', () => { wrapper.find('button').simulate('click'); await act(async () => { - const label = wrapper.find('.pgn__checkbox-filter').at(0); + const label = wrapper.find('.pgn__form-checkbox').at(0); const badge = label.find(Badge); expect(badge).toHaveLength(1); expect(badge.text()).toEqual(String(roan.number)); @@ -89,8 +89,8 @@ describe('', () => { wrapper.find('button').simulate('click'); await act(async () => { - const label = wrapper.find('.pgn__checkbox-filter').at(1); - const badge = label.find(Badge); + const label = wrapper.find('.pgn__form-checkbox').at(1); + const badge = label.find('.badge'); expect(badge).toHaveLength(0); }); }); diff --git a/src/hooks/useArrowKeyNavigation.mdx b/src/hooks/useArrowKeyNavigation.mdx index 6b0e6936d5..d6629f7bde 100644 --- a/src/hooks/useArrowKeyNavigation.mdx +++ b/src/hooks/useArrowKeyNavigation.mdx @@ -64,7 +64,7 @@ the `arrowUp` and `arrowLeft` keys can be ignored for convenient editing of the - + Confirm the entered data