File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
src/components/MultiSelect Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ export const SearchExample: Story = {
5858 group : i % 2 === 0 ? "Group 1" : "Group 2" ,
5959 } ) ) ,
6060 ] ,
61+ id : "search-id" ,
6162 } ,
6263} ;
6364
@@ -120,5 +121,6 @@ export const WithoutSorting: Story = {
120121 variant : "condensed" ,
121122 isSortedAlphabetically : false ,
122123 hasSelectedItemsFirst : false ,
124+ id : "external-id" ,
123125 } ,
124126} ;
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ export type MultiSelectProps = {
3434 scrollOverflow ?: boolean ;
3535 isSortedAlphabetically ?: boolean ;
3636 hasSelectedItemsFirst ?: boolean ;
37+ id ?: string ;
3738} ;
3839
3940type ValueSet = Set < MultiSelectItem [ "value" ] > ;
@@ -203,6 +204,7 @@ export const MultiSelect: React.FC<MultiSelectProps> = ({
203204 scrollOverflow = false ,
204205 isSortedAlphabetically = true ,
205206 hasSelectedItemsFirst = true ,
207+ id,
206208} : MultiSelectProps ) => {
207209 const buttonRef = useRef ( null ) ;
208210 const [ isDropdownOpen , setIsDropdownOpen ] = useState ( false ) ;
@@ -286,7 +288,7 @@ export const MultiSelect: React.FC<MultiSelectProps> = ({
286288 externallyControlled
287289 aria-controls = { dropdownId }
288290 aria-expanded = { isDropdownOpen }
289- id = { inputId }
291+ id = { id ?? inputId }
290292 role = "combobox"
291293 aria-label = { label || placeholder || "Search" }
292294 disabled = { disabled }
@@ -328,6 +330,7 @@ export const MultiSelect: React.FC<MultiSelectProps> = ({
328330 }
329331 } }
330332 ref = { buttonRef }
333+ id = { id }
331334 >
332335 < span className = "multi-select__condensed-text" >
333336 { listSelected && selectedItems . length > 0
You can’t perform that action at this time.
0 commit comments