File tree Expand file tree Collapse file tree 4 files changed +11
-8
lines changed
packages/pluggableWidgets/combobox-web/src Expand file tree Collapse file tree 4 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ export default function Combobox(props: ComboboxContainerProps): ReactElement {
25
25
noOptionsText : props . noOptionsText ?. value ,
26
26
readOnlyStyle : props . readOnlyStyle ,
27
27
ariaRequired : props . ariaRequired ,
28
+ ariaLabel : props . ariaLabel ?. value ,
28
29
a11yConfig : {
29
30
ariaLabels : {
30
31
clearSelection : props . clearButtonAriaLabel ?. value ?? "" ,
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ export function MultiSelection({
37
37
const inputRef = useRef < HTMLInputElement > ( null ) ;
38
38
const isSelectedItemsBoxStyle = selector . selectedItemsStyle === "boxes" ;
39
39
const isOptionsSelected = selector . isOptionsSelected ( ) ;
40
+ const inputLabel = getInputLabel ( options . inputId ) ;
41
+ const hasLabel = useMemo ( ( ) => Boolean ( inputLabel ) , [ inputLabel ] ) ;
40
42
const inputProps = getInputProps ( {
41
43
...getDropdownProps (
42
44
{
@@ -62,12 +64,10 @@ export function MultiSelection({
62
64
} ,
63
65
disabled : selector . readOnly ,
64
66
readOnly : selector . options . filterType === "none" ,
65
- "aria-required" : ariaRequired . value
67
+ "aria-required" : ariaRequired . value ,
68
+ "aria-label" : ! hasLabel && options . ariaLabel ? options . ariaLabel : undefined
66
69
} ) ;
67
70
68
- const inputLabel = getInputLabel ( inputProps . id ) ;
69
- const hasLabel = useMemo ( ( ) => Boolean ( inputLabel ) , [ inputLabel ] ) ;
70
-
71
71
const memoizedselectedCaptions = useMemo (
72
72
( ) => getSelectedCaptionsPlaceholder ( selector , selectedItems ) ,
73
73
[ selector , selectedItems ]
Original file line number Diff line number Diff line change @@ -56,19 +56,20 @@ export function SingleSelection({
56
56
]
57
57
) ;
58
58
59
+ const inputLabel = getInputLabel ( options . inputId ) ;
60
+ const hasLabel = useMemo ( ( ) => Boolean ( inputLabel ) , [ inputLabel ] ) ;
61
+
59
62
const inputProps = getInputProps (
60
63
{
61
64
disabled : selector . readOnly ,
62
65
readOnly : selector . options . filterType === "none" ,
63
66
ref : inputRef ,
64
- "aria-required" : ariaRequired . value
67
+ "aria-required" : ariaRequired . value ,
68
+ "aria-label" : ! hasLabel && options . ariaLabel ? options . ariaLabel : undefined
65
69
} ,
66
70
{ suppressRefError : true }
67
71
) ;
68
72
69
- const inputLabel = getInputLabel ( inputProps . id ) ;
70
- const hasLabel = useMemo ( ( ) => Boolean ( inputLabel ) , [ inputLabel ] ) ;
71
-
72
73
return (
73
74
< Fragment >
74
75
< ComboboxWrapper
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ export interface SelectionBaseProps<Selector> {
100
100
menuFooterContent ?: ReactNode ;
101
101
tabIndex : number ;
102
102
ariaRequired : DynamicValue < boolean > ;
103
+ ariaLabel ?: string ;
103
104
a11yConfig : {
104
105
ariaLabels : {
105
106
clearSelection : string ;
You can’t perform that action at this time.
0 commit comments