Skip to content

Commit f4e90f0

Browse files
committed
Update prop name and add tests
1 parent dcf3e27 commit f4e90f0

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

packages/react-core/src/components/SearchInput/SearchInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
301301
onKeyDown={onEnter}
302302
onChange={onChangeHandler}
303303
name={name}
304-
id={searchInputId}
304+
inputId={searchInputId}
305305
/>
306306
{(renderUtilities || areUtilitiesDisplayed) && (
307307
<TextInputGroupUtilities>

packages/react-core/src/components/TextInputGroup/TextInputGroupMain.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export interface TextInputGroupMainProps extends Omit<React.HTMLProps<HTMLDivEle
5454
/** @beta The id of the element(s) controlled by the input. Required if role has a value of "combobox". */
5555
'aria-controls'?: string;
5656
/** The id of the input element */
57-
id?: string;
57+
inputId?: string;
5858
}
5959

6060
const TextInputGroupMainBase: React.FunctionComponent<TextInputGroupMainProps> = ({
@@ -75,7 +75,7 @@ const TextInputGroupMainBase: React.FunctionComponent<TextInputGroupMainProps> =
7575
role,
7676
isExpanded,
7777
'aria-controls': ariaControls,
78-
id,
78+
inputId,
7979
...props
8080
}: TextInputGroupMainProps) => {
8181
const { isDisabled } = React.useContext(TextInputGroupContext);
@@ -97,7 +97,7 @@ const TextInputGroupMainBase: React.FunctionComponent<TextInputGroupMainProps> =
9797
disabled
9898
aria-hidden="true"
9999
value={hint}
100-
id={id}
100+
id={inputId}
101101
/>
102102
)}
103103
{icon && <span className={css(styles.textInputGroupIcon)}>{icon}</span>}
@@ -114,7 +114,7 @@ const TextInputGroupMainBase: React.FunctionComponent<TextInputGroupMainProps> =
114114
placeholder={inputPlaceHolder}
115115
name={name}
116116
aria-activedescendant={ariaActivedescendant}
117-
id={id}
117+
id={inputId}
118118
{...(role && { role })}
119119
{...(isExpanded !== undefined && { 'aria-expanded': isExpanded })}
120120
{...(ariaControls && { 'aria-controls': ariaControls })}

packages/react-core/src/components/TextInputGroup/__tests__/TextInputGroupMain.test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ describe('TextInputGroupMain', () => {
109109
expect(inputValue).toBeVisible();
110110
});
111111

112+
it('passes the inputId prop to the input', () => {
113+
render(<TextInputGroupMain inputId="input-id">Test</TextInputGroupMain>);
114+
115+
const input = screen.getByRole('textbox');
116+
117+
expect(input).toHaveAttribute('id', 'input-id');
118+
});
119+
112120
it('passes the placeholder prop to the input', () => {
113121
render(<TextInputGroupMain placeholder="placeholder text">Test</TextInputGroupMain>);
114122

0 commit comments

Comments
 (0)