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

[Bug]: The "required" attribute on checkbox is broken #33193

Open
2 tasks done
mtas-test opened this issue Nov 1, 2024 · 1 comment
Open
2 tasks done

[Bug]: The "required" attribute on checkbox is broken #33193

mtas-test opened this issue Nov 1, 2024 · 1 comment
Labels
Component: Checkbox Fluent UI react (v8) Issues about @fluentui/react (v8) Resolution: Won't Do Requests reviewed; concluded to not approve for prioritization. Type: Feature

Comments

@mtas-test
Copy link

Package

react

Package version

8.12.7

React version

16.14.0

Environment

web

Current Behavior

Adding the "required" attribute doesn't enforce a required behavior. I couldn't see a red (*) beside the label or checkbox component.

Expected Behavior

Adding the "required" attribute should enforce a required behavior and show a red (*) beside the checkbox/label

Reproduction

https://codepen.io/pen

Steps to reproduce

Go to https://developer.microsoft.com/en-us/fluentui#/controls/web/checkbox
Click on any "Export to codepen" https://codepen.io/pen
Add "required" to any Checkbox component (Example: )
Observe that there is no red (*) and the "required" behavior is not enforced

Are you reporting an Accessibility issue?

None

Suggested severity

High - No workaround

Products/sites affected

account.microsoft.com/privacy

Are you willing to submit a PR to fix?

no

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@smhigley
Copy link
Contributor

smhigley commented Nov 1, 2024

@mtas-test thanks for filing the issue! It looks like it probably would have been a good idea to make a required v8 Checkbox label style, but unfortunately adding one now would be a breaking change for v8. I have made a Codepen to demonstrate how to make your own custom required "*" style that matches the one on Textfield: https://codepen.io/smhigley/pen/JjgZWXa?editors=1010

I don't really know what you mean by enforcing required behavior -- we don't provide out-of-the-box form validation in Fluent, that is generally left up to product teams. Setting the required attribute on the Fluent Checkbox does actually set the native required HTML attribute on the underlying <input type="checkbox">, which will trigger native browser validation on the checkbox on form submit, if you're not turning that off. Even if native validation is not used, setting required will provide the required semantics to show that the checkbox is required to e.g. screen reader users.

Hope that helps! Feel free to reach out with any other questions.

@smhigley smhigley added Type: Feature Component: Checkbox Resolution: Won't Do Requests reviewed; concluded to not approve for prioritization. and removed Type: Bug 🐛 Needs: Triage 🔍 labels Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Checkbox Fluent UI react (v8) Issues about @fluentui/react (v8) Resolution: Won't Do Requests reviewed; concluded to not approve for prioritization. Type: Feature
Projects
None yet
Development

No branches or pull requests

2 participants