Skip to content

Commit

Permalink
Remove -field postfix from id so that the id prop received is what is…
Browse files Browse the repository at this point in the history
… used
  • Loading branch information
beaesguerra committed Nov 18, 2024
1 parent e0569b1 commit bed91f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-fireants-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/wonder-blocks-search-field": minor
---

SearchField: Remove "-field" that was automatically appended to the id.
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ describe("SearchField", () => {
const searchField = await screen.findByTestId("search-field-test");

// Assert
expect(searchField).toHaveAttribute("id", "some-random-id-field");
expect(searchField).toHaveAttribute("id", "some-random-id");
});

test("uses a unique ID if one is not provided", async () => {
Expand All @@ -387,9 +387,7 @@ describe("SearchField", () => {
const searchField = await screen.findByTestId("search-field-test");

// Assert
expect(searchField.getAttribute("id")).toMatch(
/^uid-search-field.*-field$/,
);
expect(searchField.getAttribute("id")).toMatch(/^uid-search-field.*$/);
});

test("has focus if autoFocus is true", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const SearchField: React.ForwardRefExoticComponent<
aria-hidden="true"
/>
<TextField
id={`${uniqueId}-field`}
id={uniqueId}
type="text"
autoFocus={autoFocus}
disabled={disabled}
Expand Down

0 comments on commit bed91f4

Please sign in to comment.