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

Cannot use Checkbox as an uncontrolled component #6753

Open
gianmarcotoso opened this issue Jun 12, 2024 · 0 comments
Open

Cannot use Checkbox as an uncontrolled component #6753

gianmarcotoso opened this issue Jun 12, 2024 · 0 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@gianmarcotoso
Copy link

Describe the bug

Checkboxes (and all other inputs) should be usable as uncontrolled components, allowing for native HTML Form behavior.

Reproducer

N/A

PrimeReact version

10.6.6

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

Any/All

Steps to reproduce the behavior

  1. Add a Checkbox component inside a form without specifying a checked prop:
  2. Click the checkbox
  3. Nothing happens

Expected behavior

The checkbox should behave as a native HTML checkbox, and only work as a controlled component when state is explicitly passed via the checked prop.

PS > I see that the current solution to this was to remove the defaultChecked prop from the Checkbox component to make it exclusively controlled. In my humble opinion, this is a step backwards as default HTML behavior should always be preserved in component libraries, at least for standard components that are already available in the browser.

@gianmarcotoso gianmarcotoso added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant