Skip to content

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

Merged
RobinMalfait merged 2 commits intomainfrom
fix/issue-3623
Feb 13, 2025
Merged

Fix aria-invalid attributes to have a valid 'true' value#3639
RobinMalfait merged 2 commits intomainfrom
fix/issue-3623

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;
  }
}
```
@vercel
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
Contributor

@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

@RobinMalfait RobinMalfait enabled auto-merge (squash) February 13, 2025 14:49
@RobinMalfait RobinMalfait merged commit 87252e1 into main Feb 13, 2025
7 of 8 checks passed
@RobinMalfait RobinMalfait deleted the fix/issue-3623 branch February 13, 2025 14:50
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