@@ -258,7 +296,7 @@ describe("FieldItem", () => {
const button = container.querySelector("button");
const label = container.querySelector("label");
const selectTarget = container.querySelector('[role="combobox"]');
- expect(button).toHaveAttribute("aria-hidden", "true");
+ expect(selectTarget).toHaveAccessibleName("Type");
rerender(
@@ -267,7 +305,6 @@ describe("FieldItem", () => {
,
);
- expect(button).not.toHaveAttribute("aria-hidden");
expect(label).toHaveAttribute("for", button?.id);
expect(selectTarget).not.toHaveAttribute("id");
expect(selectTarget).not.toHaveAttribute("aria-labelledby");
@@ -281,7 +318,6 @@ describe("FieldItem", () => {
);
expect(label).not.toHaveAttribute("for");
expect(container.querySelector('[role="combobox"]')).toHaveAccessibleName("Type");
- expect(button).toHaveAttribute("aria-hidden", "true");
expect(button).not.toHaveAttribute("id");
});
it("should remove the reference to a removed label from `aria-labelledby`", () => {
@@ -348,6 +384,59 @@ describe("FieldItem", () => {
expect(input).toHaveAttribute("aria-labelledby", "customlabel");
expect(input).toHaveAttribute("aria-describedby", "customhelp");
});
+ it("should remove a label ID of the application from `aria-labelledby` if another input element is connected", () => {
+ const fieldItem = (htmlFor?: string) => (
+