diff --git a/src/DataTable/filters/CheckboxFilter.jsx b/src/DataTable/filters/CheckboxFilter.jsx index 83780665b2b..dd8ee7ea946 100644 --- a/src/DataTable/filters/CheckboxFilter.jsx +++ b/src/DataTable/filters/CheckboxFilter.jsx @@ -3,7 +3,6 @@ import PropTypes from 'prop-types'; import Form, { FormLabel } from '../../Form'; import Badge from '../../Badge'; import { newId } from '../../utils'; -import LabelledCheckbox from './LabelledCheckbox'; function CheckboxFilter({ column: { @@ -27,15 +26,19 @@ 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 64e217d261a..00000000000 --- 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 39458c50147..2a63abe9c43 100644 --- a/src/DataTable/filters/MultiSelectDropdownFilter.jsx +++ b/src/DataTable/filters/MultiSelectDropdownFilter.jsx @@ -1,9 +1,9 @@ -import React, { useRef, useMemo } from 'react'; +import React, { useRef } from 'react'; import PropTypes from 'prop-types'; import Badge from '../../Badge'; import { DropdownButton } from '../../Dropdown'; import { newId } from '../../utils'; -import LabelledCheckbox from './LabelledCheckbox'; +import Form from '../../Form'; function MultiSelectDropdownFilter({ column: { @@ -21,20 +21,22 @@ 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}}} - /> + 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 9281bbe7edb..50b3d01c703 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 1ced27ddfd7..80f381a78ee 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,9 @@ 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 6b0e6936d58..be21e04756f 100644 --- a/src/hooks/useArrowKeyNavigation.mdx +++ b/src/hooks/useArrowKeyNavigation.mdx @@ -64,7 +64,9 @@ the `arrowUp` and `arrowLeft` keys can be ignored for convenient editing of the - + + Confirm the entered data +