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

*ByRole form seems not to find <form /> elements #1021

Closed
svenliebig opened this issue Sep 2, 2021 · 2 comments
Closed

*ByRole form seems not to find <form /> elements #1021

svenliebig opened this issue Sep 2, 2021 · 2 comments

Comments

@svenliebig
Copy link

svenliebig commented Sep 2, 2021

Versions:

  • @testing-library/react: ^11.2.5,
  • @testing-library/dom: 7.29.4
  • @testing-library/jest-dom: ^5.11.9,

Testcase:

it(`testcase`, async () => {
    render(
        <div>
            <h1>helloworld</h1>
            <form>
                <h2>content</h2>
                <label htmlFor="tinput">hello</label>
                <input type="text" id="tinput" />
            </form>
        </div>
    )

    expect(screen.getByRole("form")).toBeInTheDocument()
})

result:

    Unable to find role="form"

    <body
      class=""
    >
      <div>
          <h1>
            helloworld
          </h1>
          <form>
            <h2>
              content
            </h2>
            <label
              for="tinput"
            >
              hello
            </label>
            <input
              id="tinput"
              type="text"
            />
          </form>
        </div>
    </body>

Expected result:

Find the form as a representation of a form role element.

Problem description:

The form should be recognized as a aria form role, or am I wrong? https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Form_Role

Thanks for your effort!

@eps1lon
Copy link
Member

eps1lon commented Sep 2, 2021

Thanks for the feedback.

We closely follow ARIA specifications. html-aam specifies that <form /> only has the form role if it has an accessible name.

Hope this clears things up. If you think <form /> should always have the form role, please open an issue on the html-aam repository. But please consider prior discussions such as w3c/html-aria#94

@eps1lon eps1lon closed this as completed Sep 2, 2021
@svenliebig
Copy link
Author

svenliebig commented Sep 2, 2021

Thanks for pointing that out! I'll give it a name then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants