From 26d26ac3e1d13e2a294156762428777d344f2607 Mon Sep 17 00:00:00 2001 From: Kiarokh Moattar Date: Wed, 3 Apr 2024 14:16:32 +0200 Subject: [PATCH] fix(input-field): ensure `aria-controls` get ids of both helper text & portal --- src/components/input-field/input-field.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/input-field/input-field.tsx b/src/components/input-field/input-field.tsx index 057f9bf7b3..f588f94c69 100644 --- a/src/components/input-field/input-field.tsx +++ b/src/components/input-field/input-field.tsx @@ -299,11 +299,25 @@ export class InputField { properties.readonly = this.readonly; properties.disabled = this.disabled || this.readonly; + let ariaControls = ''; + if (this.hasHelperText()) { - properties['aria-controls'] = this.helperTextId; + ariaControls += this.helperTextId; properties['aria-describedby'] = this.helperTextId; } + if (this.renderAutocompleteList()) { + if (ariaControls) { + ariaControls += ' '; + } + + ariaControls += this.portalId; + } + + if (ariaControls) { + properties['aria-controls'] = ariaControls; + } + return [