Skip to content

Commit dda2d4b

Browse files
committed
[EuiAbsoluteTab][EuiRelativeTab] Link text input with label
1 parent 92c945e commit dda2d4b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

packages/eui/src/components/date_picker/super_date_picker/date_popover/absolute_tab.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const EuiAbsoluteTab: FunctionComponent<EuiAbsoluteTabProps> = ({
9090
[dateFormat]
9191
);
9292

93+
const textInputLabelId = useGeneratedHtmlId();
9394
const timeZomeDescriptionId = useGeneratedHtmlId();
9495
const submitButtonLabel = useEuiI18n(
9596
'euiAbsoluteTab.dateFormatButtonLabel',
@@ -205,6 +206,7 @@ export const EuiAbsoluteTab: FunctionComponent<EuiAbsoluteTabProps> = ({
205206
describedByIds={[timeZomeDescriptionId]}
206207
>
207208
<EuiFieldText
209+
aria-labelledby={textInputLabelId}
208210
compressed
209211
isInvalid={isTextInvalid}
210212
value={textInputValue}
@@ -218,7 +220,9 @@ export const EuiAbsoluteTab: FunctionComponent<EuiAbsoluteTabProps> = ({
218220
setIsReadyToParse(true);
219221
}}
220222
data-test-subj="superDatePickerAbsoluteDateInput"
221-
prepend={<EuiFormLabel>{labelPrefix}</EuiFormLabel>}
223+
prepend={
224+
<EuiFormLabel id={textInputLabelId}>{labelPrefix}</EuiFormLabel>
225+
}
222226
/>
223227
</EuiFormRow>
224228
{hasUnparsedText && (

packages/eui/src/components/date_picker/super_date_picker/date_popover/relative_tab.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export const EuiRelativeTab: FunctionComponent<EuiRelativeTabProps> = ({
120120
return parsedValue.locale(locale || 'en').format(dateFormat);
121121
}, [isInvalid, value, roundUp, locale, dateFormat]);
122122

123+
const textInputLabelId = useGeneratedHtmlId();
123124
const relativeDateInputNumberDescriptionId = useGeneratedHtmlId();
124125
const timeZomeDescriptionId = useGeneratedHtmlId();
125126
const numberAriaLabel = useEuiI18n(
@@ -178,11 +179,14 @@ export const EuiRelativeTab: FunctionComponent<EuiRelativeTabProps> = ({
178179
</EuiFlexGroup>
179180
<EuiSpacer size="s" />
180181
<EuiFieldText
182+
aria-labelledby={textInputLabelId}
181183
compressed
182184
value={formattedValue}
183185
readOnly
184186
aria-describedby={timeZomeDescriptionId}
185-
prepend={<EuiFormLabel>{labelPrefix}</EuiFormLabel>}
187+
prepend={
188+
<EuiFormLabel id={textInputLabelId}>{labelPrefix}</EuiFormLabel>
189+
}
186190
/>
187191
<EuiScreenReaderOnly>
188192
<p id={relativeDateInputNumberDescriptionId}>

0 commit comments

Comments
 (0)