FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(Checkbox): Set checked value correctly by boaz0 · Pull Request #1929 · patternfly/patternfly-react · GitHub

fix(Checkbox): Set checked value correctly - #1929

Merged
tlabaj merged 1 commit into
patternfly:masterfrom
boaz0:fix_checkbox
May 16, 2019
Merged

fix(Checkbox): Set checked value correctly#1929
tlabaj merged 1 commit into
patternfly:masterfrom
boaz0:fix_checkbox

Conversation

boaz0 commented May 5, 2019
edited
Loading

Copy link
Copy Markdown
Member

What:

closes #1959

I first realized that the controlled Checkbox example is wrong: event.target.name 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: https://fb.me/react-controlled-components
    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 https://github.com/project-koku/koku-ui/issues/841

Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>

Copy link
Copy Markdown
Collaborator

PatternFly-React preview: https://1929-pr-patternfly-react-patternfly.surge.sh

codecov-io commented May 5, 2019
edited
Loading

Copy link
Copy Markdown

Codecov Report

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

@@            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.

tlabaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@boaz0 can you add issue number to the description

tlabaj added PF4 labels May 8, 2019

boaz0 commented May 9, 2019

Copy link
Copy Markdown
Member Author

Done 👍

tlabaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

tlabaj merged commit 43d5283 into patternfly:master May 16, 2019

boaz0 commented May 17, 2019

Copy link
Copy Markdown
Member Author

Thanks @tlabaj & @dlabrecq

boaz0 deleted the fix_checkbox branch May 17, 2019 07:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Checkbox controlled failure Onboarding checkboxes generate warnings

5 participants


Back | FazBrowse Home | New Git URL