Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchField: Remove -field postfix from id #2365

Open
wants to merge 2 commits into
base: search-field-updates
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": patch
---

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 @@ -208,7 +208,7 @@ const SearchField: React.ForwardRefExoticComponent<
aria-hidden="true"
/>
<TextField
id={`${uniqueId}-field`}
id={uniqueId}
type="text"
autoFocus={autoFocus}
disabled={disabled}
Expand Down