Skip to content

Commit a86434e

Browse files
(Input): switch to specify labelId based on whether label exists
1 parent 432a147 commit a86434e

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/scripts/Input.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,13 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
165165

166166
const prefix = useId();
167167

168-
const labelId = `${prefix}-label-id`;
169-
170168
const rawTextId = id ?? `${prefix}-raw-text-id`;
171169
const inputId = id ?? `${prefix}-input-id`;
172170
const labelForId = readOnly ? rawTextId : inputId;
173171

172+
const labelId = label ? `${prefix}-label-id` : undefined;
174173
const preAddonId = addonLeft ? `${prefix}-pre-addon-id` : undefined;
175-
176174
const postAddonId = addonRight ? `${prefix}-post-addon-id` : undefined;
177-
178175
const labelledBy = [labelId, preAddonId, postAddonId]
179176
.filter((id) => id !== undefined)
180177
.join(' ');

0 commit comments

Comments
 (0)