Skip to content

Commit aea7fe5

Browse files
authored
fix: dynamically set label to match id (#1195)
1 parent 66c38a3 commit aea7fe5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/components/CustomSelect/CustomSelectDropdown/__snapshots__/CustomSelectDropdown.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports[`CustomSelectDropdown renders 1`] = `
1616
>
1717
<label
1818
class="u-off-screen"
19-
for="search"
19+
for="select-search-test-dropdown"
2020
>
2121
Search
2222
</label>

src/components/SearchBox/SearchBox.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export type Props = PropsWithSpread<
6868
const SearchBox = React.forwardRef<HTMLInputElement, Props>(
6969
(
7070
{
71+
name = "search",
72+
id = "search",
7173
autocomplete = "on",
7274
className,
7375
disabled,
@@ -108,15 +110,15 @@ const SearchBox = React.forwardRef<HTMLInputElement, Props>(
108110

109111
return (
110112
<div className={classNames("p-search-box", className)}>
111-
<label className="u-off-screen" htmlFor="search">
113+
<label className="u-off-screen" htmlFor={id}>
112114
{placeholder || "Search"}
113115
</label>
114116
<input
115117
autoComplete={autocomplete}
116118
className="p-search-box__input"
117119
disabled={disabled}
118-
id="search"
119-
name="search"
120+
id={id}
121+
name={name}
120122
onChange={(evt) => onChange?.(evt.target.value)}
121123
onKeyDown={onKeyDown}
122124
placeholder={placeholder}

0 commit comments

Comments
 (0)