Aitema-gmbh commented on code in PR #39245:
URL: https://github.com/apache/superset/pull/39245#discussion_r3232734928
##########
superset-frontend/src/explore/components/controls/NumberControl/index.tsx:
##########
@@ -71,6 +71,12 @@ export default function NumberControl({
onChange?.(pendingValueRef.current);
};
+ const hasErrors =
+ rest.validationErrors && rest.validationErrors.length > 0;
+ const errorId = hasErrors
+ ? `${rest.name || 'number-control'}-error`
Review Comment:
ADDRESSED: NumberControl now passes its `errorId` to ControlHeader via the
new prop instead of generating a second one (commit 7938a0d). There is exactly
one element with id=`${inputId}-error` per control.
##########
superset-frontend/src/explore/components/controls/NumberControl/index.tsx:
##########
@@ -84,7 +90,19 @@ export default function NumberControl({
onBlur={handleBlur}
disabled={disabled}
aria-label={rest.label}
+ aria-invalid={hasErrors || undefined}
+ aria-describedby={errorId}
+ id={rest.name}
/>
+ {hasErrors && (
+ <span
+ id={errorId}
+ role="alert"
Review Comment:
ADDRESSED: The inline `<span>` in NumberControl no longer carries
role="alert"; only the visually-hidden span inside ControlHeader does. Single
announcement per validation change (commit 7938a0d, NumberControl.tsx lines
114–118).
##########
superset-frontend/src/components/Modal/ModalFormField.tsx:
##########
@@ -128,16 +128,36 @@ export function ModalFormField({
validateStatus,
hasFeedback = false,
}: ModalFormFieldProps) {
+ const uniqueId = useId();
+ const errorId = error ? `${uniqueId}-error` : undefined;
+
+ // Clone the first child element to inject aria-invalid and aria-describedby
+ const enhancedChildren = error
+ ? Children.map(children, (child, index) => {
+ if (index === 0 && isValidElement(child)) {
+ return cloneElement(child as React.ReactElement<any>, {
+ 'aria-invalid': true,
+ 'aria-describedby': errorId,
+ });
+ }
+ return child;
Review Comment:
ADDRESSED: `applyAria` in ModalFormField now detects wrapper elements with a
single valid child (e.g. AntD `FormItem`) and applies
`aria-invalid`/`aria-describedby` to the wrapped control via a nested
`cloneElement` (commit 7938a0d, lines 143–155). Falls back to applying on the
direct child when there is no wrapper.
##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -2119,6 +2119,14 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
<ModalFormField
label={isReport ? t('Report name') : t('Alert name')}
required
+ error={
+ validationStatus[Sections.General].hasErrors &&
+ !currentAlert?.name?.length
Review Comment:
ADDRESSED: The name error now gates on `currentAlert &&
validationStatus[Sections.General].hasErrors && !currentAlert.name?.length`
(commit c822114, AlertReportModal.tsx line 2136–2138). No false role=alert
during edit-load.
##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -2131,7 +2139,16 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
onChange={onInputChange}
/>
</ModalFormField>
- <ModalFormField label={t('Owners')} required>
+ <ModalFormField
+ label={t('Owners')}
+ required
+ error={
+ validationStatus[Sections.General].hasErrors &&
+ !currentAlert?.owners?.length
Review Comment:
ADDRESSED: Same gating pattern applied to the owners error — `currentAlert
&& validationStatus[Sections.General].hasErrors &&
!currentAlert.owners?.length` (commit c822114, line 2160–2162).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]