Skip to content

Commit 62555a3

Browse files
authored
aria-controls on multiselect panel (#8241)
1 parent 68353a0 commit 62555a3

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

components/lib/multiselect/MultiSelect.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { TimesIcon } from '../icons/times';
88
import { TimesCircleIcon } from '../icons/timescircle';
99
import { OverlayService } from '../overlayservice/OverlayService';
1010
import { Tooltip } from '../tooltip/Tooltip';
11-
import { DomHandler, IconUtils, ObjectUtils, ZIndexUtils, classNames } from '../utils/Utils';
11+
import { DomHandler, IconUtils, ObjectUtils, UniqueComponentId, ZIndexUtils, classNames } from '../utils/Utils';
1212
import { MultiSelectBase } from './MultiSelectBase';
1313
import { MultiSelectPanel } from './MultiSelectPanel';
1414

@@ -1174,7 +1174,9 @@ export const MultiSelect = React.memo(
11741174
},
11751175
ptm('hiddenInputWrapper')
11761176
);
1177-
1177+
const inputId = React.useMemo(() => {
1178+
return props.inputId ?? UniqueComponentId();
1179+
}, [props.inputId]);
11781180
const inputProps = mergeProps(
11791181
{
11801182
ref: inputRef,
@@ -1186,6 +1188,7 @@ export const MultiSelect = React.memo(
11861188
onKeyDown: onKeyDown,
11871189
role: 'combobox',
11881190
'aria-expanded': overlayVisibleState,
1191+
'aria-controls': `${inputId}-multi-selectbox`,
11891192
disabled: props.disabled,
11901193
tabIndex: !props.disabled ? props.tabIndex : -1,
11911194
value: getLabel(),
@@ -1213,6 +1216,7 @@ export const MultiSelect = React.memo(
12131216
ref={overlayRef}
12141217
visibleOptions={visibleOptions}
12151218
{...props}
1219+
listId={`${inputId}-multi-selectbox`}
12161220
onClick={onPanelClick}
12171221
onOverlayHide={hide}
12181222
filterValue={filterValue}

components/lib/multiselect/MultiSelectPanel.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ export const MultiSelectPanel = React.memo(
217217
style: options.style,
218218
className: classNames(options.className, cx('list', { virtualScrollerProps: props.virtualScrollerOptions })),
219219
role: 'listbox',
220-
'aria-multiselectable': true
220+
'aria-multiselectable': true,
221+
id: props.listId
221222
},
222223
getPTOptions('list')
223224
);
@@ -244,7 +245,8 @@ export const MultiSelectPanel = React.memo(
244245
{
245246
className: cx('list'),
246247
role: 'listbox',
247-
'aria-multiselectable': true
248+
'aria-multiselectable': true,
249+
id: props.listId
248250
},
249251
getPTOptions('list')
250252
);

0 commit comments

Comments
 (0)