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
[Checkbox] Fix regression when disabled #1467
Conversation
@@ -45,27 +45,10 @@ const getUniqueID = createUniqueIDFactory('Checkbox'); | |||
class Checkbox extends React.PureComponent<CombinedProps, never> { | |||
private inputNode = React.createRef<HTMLInputElement>(); | |||
|
|||
componentDidMount() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the logic that caused the regression -> componentDidMount/Update
@@ -165,6 +158,18 @@ describe('<Checkbox />', () => { | |||
); | |||
expect(element.find('input').prop('disabled')).toBeFalsy(); | |||
}); | |||
|
|||
it('can change values when disabled', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this test to prevent regression in the future
@@ -35,20 +35,14 @@ export default function Choice({ | |||
helpText, | |||
onClick, | |||
}: Props) { | |||
function handleClick() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this logic is out of scope for the Choice
component, so it was moved to the handleInput
function in Checkbox
@danrosenthal If this looks good to you and the logic makes sense / 🎩 / review are ✅ , feel free to merge this so you can release a patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes and code coverage look great.
This fixes the test failure in web and my 🎩 confirms it also fixes the associated UI regression.
WHY are these changes introduced?
It’s unfortunate that we missed this in the
build-consumer
test. This seems to be a regression caused by not fully understanding #1363. In #1369 I made it so Checkbox cannot be disabled and checked. however, it seems we wanted to remove the ability to fire click events while disabled and keep the ability to changeCheckbox
checked state.WHAT is this pull request doing?
Choice
toCheckbox
How to 🎩
checked
anddisabled
states ⬇️&Copy-paste this code in
playground/Playground.tsx
: