@@ -27,7 +27,7 @@ interface UrlComboboxProps {
2727 "aria-describedby" ?: string ;
2828 className ?: string ;
2929 inputClassName ?: string ;
30- renderOption ?: ( option : ComboboxOption , isHighlighted : boolean ) => ReactNode ;
30+ renderOption ?: ( option : ComboboxOption , isHighlighted : boolean , index : number ) => ReactNode ;
3131}
3232
3333export default function UrlCombobox ( {
@@ -149,10 +149,10 @@ export default function UrlCombobox({
149149 const paddingLeft = leftIcon ? "pl-9" : "px-4" ;
150150 const paddingRight = showChevron ? "pr-10" : "pr-4" ;
151151
152- const defaultRenderOption = ( option : ComboboxOption , isHighlighted : boolean ) => (
152+ const defaultRenderOption = ( option : ComboboxOption , isHighlighted : boolean , index : number ) => (
153153 < button
154154 key = { option . value }
155- id = { `${ inputId } -option-${ filteredOptions . indexOf ( option ) } ` }
155+ id = { `${ inputId } -option-${ index } ` }
156156 type = "button"
157157 onClick = { ( ) => handleSelect ( option ) }
158158 className = { `w-full px-4 py-3 text-left focus:outline-none ${
@@ -245,8 +245,8 @@ export default function UrlCombobox({
245245 >
246246 { filteredOptions . map ( ( option , index ) => (
247247 renderOption
248- ? renderOption ( option , highlightedIndex === index )
249- : defaultRenderOption ( option , highlightedIndex === index )
248+ ? renderOption ( option , highlightedIndex === index , index )
249+ : defaultRenderOption ( option , highlightedIndex === index , index )
250250 ) ) }
251251 </ div >
252252 ) }
0 commit comments