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

Fix aria-invalid attributes to have a valid 'true' value #3639

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

RobinMalfait
Copy link
Member

This PR fixes an issue with the aria-invalid attributes on some form elements.

In theory this shouldn't matter and behaves the same as other attributes. MDN also mentions that any other value than the known set of values will be treated as true.

However, some tools, including the Accessibility tab in Google Chrome will complain because we set it to aria-invalid="".

We already used 'true' for aria-checked as well, so this change makes it more consistent.

It will also make sure that aria-invalid:flex in Tailwind CSS works as expected because this compiles to:

.aria-invalid\:flex {
  &[aria-invalid="true"] {
    display: flex;
  }
}

Which means that the current implementation didn't work in this case either.

Fixes: #3623

In theory this shouldn't matter and behaves the same as other
attributes. MDN also mentions that any other value than the known set of
values will be treated as `true`.

However, some tools, including the Accessibility tab in Google Chrome
will complain because we set it to `aria-invalid=""`.

We already used `'true'` for `aria-checked` as well, so this change
makes it more consistent.

Let's set it to `true` instead, which should still work. It will also
make sure that `aria-invalid:flex` in Tailwind CSS works as expected
because this compiles to:

```css
.aria-invalid\:flex {
  &[aria-invalid="true"] {
    display: flex;
  }
}
```
Copy link

vercel bot commented Feb 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 13, 2025 2:50pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 13, 2025 2:50pm

Copy link
Member

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

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

Successfully merging this pull request may close these issues.

Input aria-invalid attribute is being rendered without a valid ("true") value
2 participants