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

Dialog is not accessible #802

Closed
stijnverween opened this issue Feb 28, 2023 · 1 comment · Fixed by #1075
Closed

Dialog is not accessible #802

stijnverween opened this issue Feb 28, 2023 · 1 comment · Fixed by #1075
Labels
bug Something isn't working

Comments

@stijnverween
Copy link

Describe the bug

Using version 6.0.4 of happy-dom, I test my component by utilising the getByRole('dialog') method.

When updating to version 7.0.0 (or above) my tests fail on the dialog element with the error statement:

Unable to find an accessible element with the role "dialog"

If I change <dialog>...</dialog> to <div role="dialog">...</div>, the tests succeed once again.

getByRole('dialog', { hidden: true }) also makes the test succeed, but is not preferred as this means the dialog element is not accessible.

To Reproduce

Steps to reproduce the behavior:

  1. Go to this sandbox and fork
  2. Run yarn vitest
  3. See that the test succeeds
  4. Go to package.json and update happy-dom to 7.0.0 (or above)
  5. Run yarn install
  6. Run yarn vitest
  7. See that the test now fails

Expected behavior

I would expect that the test keeps succeeding, as the dialog element has been supported (and to my knowledge not updated) since 5.4.0?

@stijnverween stijnverween added the bug Something isn't working label Feb 28, 2023
capricorn86 added a commit that referenced this issue Sep 18, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
AustinAbro321 Austin Abro
… return for HTMLDialogElement when it is opened.
capricorn86 added a commit that referenced this issue Sep 18, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
AustinAbro321 Austin Abro
…ssible

#802@patch: Fixes issue with wrong computed style for "display" being…
@capricorn86
Copy link
Owner

capricorn86 commented Sep 18, 2023

Thank you for reporting @stijnverween! 🙂

Sorry for taking such a long time before answering.

The reason for why testing-library doesn't return the dialog element is because it is computed as display: none when it's closed. However, it seems like Happy DOM returned display: none when it was open as well.

I have made a fix for the issue in Happy DOM.

You will also have to update your code to <dialog open></dialog> in order for testing-library to consider it as accessible.

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v12.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants