From 1fd8bf2010fc9d73cae1050bfdda806ac5e44697 Mon Sep 17 00:00:00 2001 From: Michael Haschke Date: Thu, 10 Sep 2026 13:06:20 +0200 Subject: [PATCH 1/7] conncet FieldSet parts via aria attributes to improve accessibility --- src/components/Form/FieldItem.tsx | 87 ++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/src/components/Form/FieldItem.tsx b/src/components/Form/FieldItem.tsx index 28009a57f..a594b93ed 100644 --- a/src/components/Form/FieldItem.tsx +++ b/src/components/Form/FieldItem.tsx @@ -30,8 +30,20 @@ export interface FieldItemProps extends React.HTMLAttributes, Te * Is displayed below the included input element. */ messageText?: string; + /** + * Prevent the automatic connection of the field item parts. + * By default label, input element, helper text and message are connected to each + * other via `for`, `aria-labelledby` and `aria-describedby`. + * Set it to `true` if the using application manages the accessibility attributes itself. + */ + preventAriaAttribution?: boolean; } +/** + * Input elements that could be connected to the label and the help texts of the field item. + */ +const connectableInputSelectors = ["input", "textarea", "select", `.${eccgui}-select button`]; + /** * Form element that manages the combination of label, helper texts, input element and feedback messages. */ @@ -43,11 +55,83 @@ export const FieldItem = ({ helperText, messageText, intent, + preventAriaAttribution = false, ...otherProps }: FieldItemProps) => { + const fieldItemRef = React.useRef(null); + /** unique ID of this field item, used as suffix for the IDs of its parts */ + const fieldItemId = React.useId().replace(/[^a-zA-Z0-9_-]/g, ""); + const intentClass = intent ? " " + IntentClassNames[intent.toUpperCase()] : ""; - const label =