99 Section ,
1010 UserDefinedSection ,
1111 HTMLPropsWithCioDataAttributes ,
12+ Item ,
1213} from '../types' ;
1314import usePrevious from './usePrevious' ;
1415import {
@@ -122,7 +123,7 @@ const useCioAutocomplete = (options: UseCioAutocompleteOptions) => {
122123 closeMenu,
123124 highlightedIndex,
124125 getInputProps,
125- getItemProps,
126+ getItemProps : getItemPropsDownShift ,
126127 } = useDownShift ( { setQuery, items, onSubmit, cioClient, previousQuery } ) ;
127128
128129 // Log console errors
@@ -142,19 +143,24 @@ const useCioAutocomplete = (options: UseCioAutocompleteOptions) => {
142143 ...getMenuProps ( ) ,
143144 className : 'cio-results' ,
144145 'data-testid' : 'cio-results' ,
146+ 'data-cnstrc-autosuggest' : '' ,
145147 } ) ,
146148 getLabelProps,
147149 openMenu,
148150 closeMenu,
149- getItemProps : ( item ) => {
151+ getItemProps : ( item : Item ) => {
150152 const { index, sectionId } = getItemPosition ( { item, items } ) ;
151153 const sectionItemTestId = `cio-item-${ sectionId ?. replace ( ' ' , '' ) } ` ;
152154
153155 return {
154- ...getItemProps ( { item, index } ) ,
156+ ...getItemPropsDownShift ( { item, index } ) ,
155157 // @deprecated `sectionItemTestId` will be removed as a className in the next major version
156158 className : `cio-item ${ sectionItemTestId } ` ,
157159 'data-testid' : sectionItemTestId ,
160+ 'data-cnstrc-item-section' : item . section ,
161+ 'data-cnstrc-item-group' : item . groupId ,
162+ 'data-cnstrc-item-name' : item . value ,
163+ 'data-cnstrc-item-id' : item . data ?. id ,
158164 } ;
159165 } ,
160166 getInputProps : ( ) => ( {
@@ -193,6 +199,7 @@ const useCioAutocomplete = (options: UseCioAutocompleteOptions) => {
193199 } ,
194200 className : 'cio-input' ,
195201 'data-testid' : 'cio-input' ,
202+ 'data-cnstrc-search-input' : '' ,
196203 placeholder,
197204 onKeyDownCapture : ( { code, key, nativeEvent } ) => {
198205 const isEnter = code === 'Enter' || key === 'Enter' ;
@@ -234,6 +241,7 @@ const useCioAutocomplete = (options: UseCioAutocompleteOptions) => {
234241 } ,
235242 className : 'cio-form' ,
236243 'data-testid' : 'cio-form' ,
244+ 'data-cnstrc-search-form' : '' ,
237245 } ) ,
238246 getSectionProps : ( section : Section ) => {
239247 // @deprecated ClassNames derived from this fn will be removed in the next major version
0 commit comments