diff --git a/src/hooks/useCombobox/__tests__/getItemProps.test.js b/src/hooks/useCombobox/__tests__/getItemProps.test.js index 8085e4d7..d0472a93 100644 --- a/src/hooks/useCombobox/__tests__/getItemProps.test.js +++ b/src/hooks/useCombobox/__tests__/getItemProps.test.js @@ -49,14 +49,14 @@ describe('getItemProps', () => { const {result} = renderUseCombobox({highlightedIndex: 2}) const itemProps = result.current.getItemProps({index: 2}) - expect(itemProps['aria-selected']).toEqual('true') + expect(itemProps['aria-selected']).toEqual(true) }) test("assign 'false' to aria-selected if item is not highlighted", () => { const {result} = renderUseCombobox({highlightedIndex: 1}) const itemProps = result.current.getItemProps({index: 2}) - expect(itemProps['aria-selected']).toEqual('false') + expect(itemProps['aria-selected']).toEqual(false) }) test("click handler is not called if it's disabled", () => { diff --git a/src/hooks/useCombobox/index.js b/src/hooks/useCombobox/index.js index 10c78b3f..4e8f0ee7 100644 --- a/src/hooks/useCombobox/index.js +++ b/src/hooks/useCombobox/index.js @@ -321,7 +321,7 @@ function useCombobox(userProps = {}) { } }), 'aria-disabled': disabled, - 'aria-selected': `${index === latestState.highlightedIndex}`, + 'aria-selected': index === latestState.highlightedIndex, id: elementIds.getItemId(index), role: 'option', ...(!disabled && { diff --git a/src/hooks/useSelect/__tests__/getItemProps.test.js b/src/hooks/useSelect/__tests__/getItemProps.test.js index 1f4a0e51..1231eedc 100644 --- a/src/hooks/useSelect/__tests__/getItemProps.test.js +++ b/src/hooks/useSelect/__tests__/getItemProps.test.js @@ -53,15 +53,15 @@ describe('getItemProps', () => { const item2Props = result.current.getItemProps({index: 2}) const item3Props = result.current.getItemProps({index: 3}) - expect(item2Props['aria-selected']).toEqual('false') - expect(item3Props['aria-selected']).toEqual('true') + expect(item2Props['aria-selected']).toEqual(false) + expect(item3Props['aria-selected']).toEqual(true) }) test("assign 'false' to aria-selected if item is not highlighted", () => { const {result} = renderUseSelect({highlightedIndex: 1}) const itemProps = result.current.getItemProps({index: 2}) - expect(itemProps['aria-selected']).toEqual('false') + expect(itemProps['aria-selected']).toEqual(false) }) test('omit click handler when disabled', () => { diff --git a/src/hooks/useSelect/index.js b/src/hooks/useSelect/index.js index e0187046..f36f840b 100644 --- a/src/hooks/useSelect/index.js +++ b/src/hooks/useSelect/index.js @@ -467,7 +467,7 @@ function useSelect(userProps = {}) { } }), 'aria-disabled': disabled, - 'aria-selected': `${item === latestState.selectedItem}`, + 'aria-selected': item === latestState.selectedItem, id: elementIds.getItemId(index), role: 'option', ...rest, diff --git a/src/hooks/useSelect/testUtils.js b/src/hooks/useSelect/testUtils.js index 6c19e886..a473077e 100644 --- a/src/hooks/useSelect/testUtils.js +++ b/src/hooks/useSelect/testUtils.js @@ -88,7 +88,7 @@ export function DropdownSelect({renderSpy, renderItem, ...props}) {
  • {stringItem}