2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export function ListBoxOption<T>(props: OptionProps<T>) {
45
45
key
46
46
} = item ;
47
47
let domProps = filterDOMProps ( item . props ) ;
48
+ delete domProps . id ;
48
49
let state = useContext ( ListBoxContext ) ;
49
50
50
51
let ref = useRef < HTMLDivElement > ( ) ;
Original file line number Diff line number Diff line change @@ -730,6 +730,21 @@ describe('ListBox', function () {
730
730
expect ( option ) . toHaveAttribute ( 'data-name' , 'Foo' ) ;
731
731
} ) ;
732
732
733
+ it ( 'item id should not get overridden by custom id' , function ( ) {
734
+ let items = [ { key : 0 , name : 'Foo' } , { key : 1 , name : 'Bar' } ] ;
735
+ let { getByRole} = render (
736
+ < Provider theme = { theme } >
737
+ < ListBox aria-label = "listbox" items = { items } >
738
+ { item => < Item id = { item . name } > { item . name } </ Item > }
739
+ </ ListBox >
740
+ </ Provider >
741
+ ) ;
742
+ act ( ( ) => jest . runAllTimers ( ) ) ;
743
+ let listbox = getByRole ( 'listbox' ) ;
744
+ let option = within ( listbox ) . getAllByRole ( 'option' ) [ 0 ] ;
745
+ expect ( option . id ) . not . toEqual ( 'Foo' ) ;
746
+ } ) ;
747
+
733
748
describe ( 'async loading' , function ( ) {
734
749
it ( 'should display a spinner while loading' , async function ( ) {
735
750
let { getByRole, rerender} = render (
0 commit comments