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(Checkbox): Set checked value correctly #1929

merged 1 commit into from May 16, 2019


Copy link

boaz0 commented May 5, 2019


closes #1959

I first realized that the controlled Checkbox example is wrong: is not set and so the state can be {check1: false, check2: false, '': false} or {check1: false, check2: false, '': true}.

After fixing it by adding the name attribute to the Checkbox components the first time I checked one of the boxes I got the following error/warning message:

Warning: A component is changing an uncontrolled input of type checkbox to be controlled.
Input elements should not switch from uncontrolled to controlled (or vice versa).
Decide between using a controlled or uncontrolled input element for 
the lifetime of the component. More info:
    in input (created by Checkbox)
    in div (created by Checkbox)
    in Checkbox (created by ControlledCheckbox)
    in ControlledCheckbox (created by ErrorBoundary)
    in ErrorBoundary (created by Context.Consumer)

It looks like the expression isChecked || checked will return undefined if isChecked is false and so when checking the box that expression changed to true which causes the component to turn to be controlled.

//cc @dlabrecq
fixes project-koku/koku-ui#841

Signed-off-by: Boaz Shuster <>

This comment has been minimized.

Copy link

patternfly-build commented May 5, 2019


This comment has been minimized.

Copy link

codecov-io commented May 5, 2019

Codecov Report

Merging #1929 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1929      +/-   ##
+ Coverage   82.63%   82.64%   +0.01%     
  Files         624      624              
  Lines        6875     6879       +4     
  Branches       93       94       +1     
+ Hits         5681     5685       +4     
  Misses       1154     1154              
  Partials       40       40
Flag Coverage Δ
#patternfly3 84.89% <ø> (ø) ⬆️
#patternfly4 79.39% <100%> (+0.02%) ⬆️
#patternflymisc 95.68% <ø> (ø) ⬆️
Impacted Files Coverage Δ
...-4/react-core/src/components/Checkbox/Checkbox.tsx 90.32% <100%> (+1.43%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6dedeee...3882833. Read the comment docs.

Copy link

tlabaj left a comment

@boaz0 can you add issue number to the description


This comment has been minimized.

Copy link
Member Author

boaz0 commented May 9, 2019

Done 👍

tlabaj approved these changes May 16, 2019
Copy link

tlabaj left a comment


@tlabaj tlabaj merged commit 43d5283 into patternfly:master May 16, 2019
2 checks passed
2 checks passed
ci/circleci: build Your tests passed on CircleCI!
continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.

Copy link
Member Author

boaz0 commented May 17, 2019

Thanks @tlabaj & @dlabrecq

@boaz0 boaz0 deleted the boaz0:fix_checkbox branch May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
5 participants
You can’t perform that action at this time.