Skip to content

Commit f051373

Browse files
committed
fix(InputGroup): propagate the label prop as an aria-label attribute to child components
1 parent 032b223 commit f051373

File tree

1 file changed

+5
-2
lines changed
  • packages/orbit-components/src/InputGroup

1 file changed

+5
-2
lines changed

packages/orbit-components/src/InputGroup/index.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import * as React from "react";
44
import cx from "clsx";
55

66
import type { Props } from "./types";
7+
import type { Props as InputFieldProps } from "../InputField/types";
8+
import type { Props as SelectProps } from "../Select/types";
79
import FormLabel from "../FormLabel";
810
import ErrorFormTooltip from "../ErrorFormTooltip";
911
import useRandomId, { useRandomIdSeed } from "../hooks/useRandomId";
@@ -135,7 +137,8 @@ const InputGroup = React.forwardRef<HTMLDivElement, Props>(
135137
Array.isArray(flex) && flex.length !== 1 ? flex[key] ?? flex[0] : flex
136138
) as string | undefined;
137139

138-
const item = child as React.ReactElement<Props>;
140+
const item = child as React.ReactElement<InputFieldProps | SelectProps>;
141+
139142
return (
140143
<div
141144
key={randomId(String(key))}
@@ -158,7 +161,7 @@ const InputGroup = React.forwardRef<HTMLDivElement, Props>(
158161
onChange: handleChange(item.props.onChange),
159162
onBlur: handleBlur(item.props.onBlur),
160163
onFocus: handleFocus(item.props.onFocus),
161-
// @ts-expect-error custom prop
164+
ariaLabel: item.props.label as string,
162165
insideInputGroup: true,
163166
})}
164167
</div>

0 commit comments

Comments
 (0)