@@ -112,17 +112,15 @@ const useComboboxContext = () => useContext(ComboboxContext);
112112/**
113113 * Use this hook to control the open state and input value of the combobox.
114114 * Pass the properties down to the DataListInput component.
115- * The isExpandedRef property can be ignored. It is for advanced use cases only.
116115 */
117116const useComboboxControls = ( { initialValue = '' , ...params } : { isExpanded : boolean ; initialValue ?: string } ) => {
118- const [ isExpanded , setIsExpanded , isExpandedRef ] = useStateRef ( params . isExpanded ) ;
117+ const [ isExpanded , setIsExpanded ] = useStateRef ( params . isExpanded ) ;
119118 const [ value , setValue ] = useState ( initialValue ) ;
120119 return {
121120 isExpanded,
122121 value,
123122 setIsExpanded,
124123 setValue,
125- isExpandedRef,
126124 } ;
127125} ;
128126
@@ -346,6 +344,7 @@ const ComboboxInput = forwardRef<HTMLInputElement, PropsWithRef<ComboboxInputPro
346344 ) ;
347345 } ,
348346) ;
347+ ComboboxInput . displayName = 'ComboboxInput' ;
349348
350349interface HighlightProps extends HTMLAttributes < HTMLElement > {
351350 currentInput ?: string ;
@@ -375,7 +374,7 @@ const Highlight: React.FC<PropsWithChildren<HighlightProps>> = ({
375374 < >
376375 { children . substring ( 0 , index ) }
377376 { as === 'mark' ? (
378- < mark { ...props } > { children . substring ( index , inputLength ) } </ mark >
377+ < mark { ...props } > { children . substring ( index , index + inputLength ) } </ mark >
379378 ) : (
380379 < span { ...props } > { children . substring ( index , inputLength ) } </ span >
381380 ) }
@@ -409,6 +408,7 @@ const ListboxOption = forwardRef<HTMLLIElement, PropsWithRef<ListboxOptionProps>
409408 ) ;
410409 } ,
411410) ;
411+ ListboxOption . displayName = 'ListboxOption' ;
412412
413413type ListboxProps = HTMLAttributes < HTMLUListElement > ;
414414
@@ -443,6 +443,7 @@ const Listbox = forwardRef<HTMLUListElement, PropsWithRef<ListboxProps>>(({ chil
443443 </ ul >
444444 ) ;
445445} ) ;
446+ Listbox . displayName = 'Listbox' ;
446447
447448/*
448449 * Combobox - high-level component
@@ -537,6 +538,7 @@ const useInternalSelectedItem = (item?: Item): [Item | undefined, (item: Item) =
537538 return [ selectedItem , setSelectedItem ] ;
538539} ;
539540
541+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
540542interface Item extends Record < string , any > {
541543 id : string ;
542544 value : string ; // Used for filtering. Used for displaying and highlighting if node not provided.
@@ -573,19 +575,6 @@ const useFilters = (
573575 return [ filtered , filteredRef ] ;
574576} ;
575577
576- const getTextboxTitle = ( isExpanded : boolean , length : number , title ?: string ) => {
577- const formattedTitle = title ? ( title [ title . length - 1 ] === '.' ? title : title + '.' ) : undefined ;
578- const ariaContent = `Listbox is ${ isExpanded ? 'expanded' : 'closed' } . ${ length } ${
579- length === 1 ? 'option matches' : 'options match'
580- } your input. Use ArrowDown to navigate between options.`;
581- return formattedTitle ? `${ formattedTitle } ${ ariaContent } ` : ariaContent ;
582- } ;
583-
584- // type LabelProps<T> = {
585- // showLabel: T;
586- // label?: T extends true ? ReactNode : string;
587- // };
588-
589578type LabelProps =
590579 | {
591580 showLabel ?: false ;
@@ -723,7 +712,6 @@ const DatalistInput = forwardRef<HTMLDivElement, PropsWithRef<DatalistInputProps
723712 onChange = { handleWith ( handleChange , inputProps ?. onChange ) }
724713 onKeyDown = { handleWith ( handleKeyDownOnInput , inputProps ?. onKeyDown ) }
725714 aria-label = { ! showLabel && typeof label === 'string' ? label : undefined }
726- title = { getTextboxTitle ( internalIsExpanded , filteredItems . length , inputProps ?. title ) }
727715 className = { `react-datalist-input__textbox ${ inputProps ?. className } ` }
728716 />
729717 { ( ( filteredItems . length && internalIsExpanded ) || isCollapsedClassName || isCollapsedStyle ) && (
@@ -739,7 +727,7 @@ const DatalistInput = forwardRef<HTMLDivElement, PropsWithRef<DatalistInputProps
739727 ...listboxProps ?. style ,
740728 } }
741729 >
742- { filteredItems . map ( ( item , i ) => (
730+ { filteredItems . map ( ( item ) => (
743731 < ListboxOption
744732 { ...listboxOptionProps }
745733 aria-label = { item . label || item . value }
@@ -760,6 +748,7 @@ const DatalistInput = forwardRef<HTMLDivElement, PropsWithRef<DatalistInputProps
760748 ) ;
761749 } ,
762750) ;
751+ DatalistInput . displayName = 'DatalistInput' ;
763752
764753export type {
765754 DatalistInputProps ,
0 commit comments