Welcome to the React feedback portal. We’re happy you’re here! If you have feedback on how to improve the React, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

1
Vote

Hi,

I'm using React Hook Form to manage form state and I had some odd behaviour with the CheckBoxComponent where the checked prop is managed state. I've created a stripped down example that just uses "useState" instead of React Hook Form which exhibits the same behaviour.

So basically if the value of the "checked" prop for the CheckBoxComponent is maintained as state and the change callback prop is passed in to update that state then clicking interactively on the control results in the visual check on the control correctly changing on the first click but the hidden input doesn't, and then on subsequent clicks the two toggle but are always displaying the opposite. Updating the state from an external event (i.e. a button) doesn't exhibit the same behaviour, it's just when clicking on the control to change its state where the issue arises.

See my example here where I've used CSS to force the hidden input to be shown to the right.

So perform the following steps:

  1. Click on the checkbox to the left of "Default" (which is the control)
  2. Observe that it becomes checked but the actual input element (normally hidden) that is managed by the control to the right remains unchecked
  3. Click on the checkbox to the left of "Default" again
  4. Observe that it becomes unchecked and the actual input element to the right toggles to checked (i.e. it is out of sync)
  5. Click on the "Check" button and observe that both become checked
  6. Click on the "Uncheck" button and observe that both become unchecked
I originally came across this sort of behaviour when I was trying to set the "required" html attribute, and discovered that using the JS component on its own (i.e. not via React) with "required" set seemed to have this issue so I thought it was solely down to that. So I reported that bug related to required, but that bug has now been fixed and now I'm still finding this oddity with the React version happening when the checked prop is managed via state is updated via the change event (with the bug happening regardless of "required" being set).