Skip to content

Commit 9742d12

Browse files
(Input): remove aria-labelledby for consistency
1 parent 7c89da9 commit 9742d12

File tree

1 file changed

+4
-30
lines changed

1 file changed

+4
-30
lines changed

src/scripts/Input.tsx

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,12 @@ function useInitComponentStyle() {
3838
/**
3939
*
4040
*/
41-
const InputAddon = ({
42-
content,
43-
id,
44-
}: {
45-
content: string;
46-
id: string | undefined;
47-
}) => (
41+
const InputAddon = ({ content }: { content: string }) => (
4842
<Text
4943
tag='span'
5044
className='slds-form-element__addon'
5145
category='body'
5246
type='regular'
53-
id={id}
5447
>
5548
{content}
5649
</Text>
@@ -169,14 +162,6 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
169162
const inputId = id ?? `${prefix}-input-id`;
170163
const labelForId = readOnly ? rawTextId : inputId;
171164

172-
const labelId = label ? `${prefix}-label-id` : undefined;
173-
const preAddonId = addonLeft ? `${prefix}-pre-addon-id` : undefined;
174-
const postAddonId = addonRight ? `${prefix}-post-addon-id` : undefined;
175-
const labelledBy =
176-
[labelId, preAddonId, postAddonId]
177-
.filter((id) => id !== undefined)
178-
.join(' ') || undefined;
179-
180165
const errorId = `${prefix}-error-id`;
181166

182167
const { isFieldSetColumn } = useContext(FieldSetColumnContext);
@@ -185,12 +170,7 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
185170
bare ? 'slds-input_bare' : 'slds-input'
186171
);
187172
const inputElem = readOnly ? (
188-
<Text
189-
id={rawTextId}
190-
type='regular'
191-
category='body'
192-
aria-labelledby={labelledBy}
193-
>
173+
<Text id={rawTextId} type='regular' category='body'>
194174
{value}
195175
</Text>
196176
) : (
@@ -205,7 +185,6 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
205185
{...rprops}
206186
onChange={onChange}
207187
onKeyDown={onKeyDown}
208-
aria-labelledby={labelledBy}
209188
aria-describedby={error ? errorId : undefined}
210189
aria-invalid={error ? true : undefined}
211190
/>
@@ -223,21 +202,16 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
223202
);
224203
contentElem = (
225204
<div className={wrapperClassName}>
226-
{addonLeft ? (
227-
<InputAddon content={addonLeft} id={preAddonId} />
228-
) : undefined}
205+
{addonLeft ? <InputAddon content={addonLeft} /> : undefined}
229206
{iconLeft ? <InputIcon icon={iconLeft} align='left' /> : undefined}
230207
{inputElem}
231208
{iconRight ? <InputIcon icon={iconRight} align='right' /> : undefined}
232-
{addonRight ? (
233-
<InputAddon content={addonRight} id={postAddonId} />
234-
) : undefined}
209+
{addonRight ? <InputAddon content={addonRight} /> : undefined}
235210
</div>
236211
);
237212
}
238213
if (isFieldSetColumn || label || required || error || cols) {
239214
const formElemProps = {
240-
id: labelId,
241215
controlId: labelForId,
242216
label,
243217
required,

0 commit comments

Comments
 (0)