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

Clean up CheckboxWithLabel refactor #8679

Closed
luacmartins opened this issue Apr 18, 2022 · 0 comments
Closed

Clean up CheckboxWithLabel refactor #8679

luacmartins opened this issue Apr 18, 2022 · 0 comments
Assignees
Labels

Comments

@luacmartins
Copy link
Contributor

luacmartins commented Apr 18, 2022

Problem

I noticed a few things that should have been different with the CheckboxWithLabel refactor:

  1. onChange was renamed to onInputChange in Form.js. We should update this and rename it in all usages of CheckboxWithLabel.
  2. The usage in Form.stories.js is incorrect. We should NOT pass onPress or isChecked to CheckboxWithLabel since Form provides the "onChange" handler automatically. We also use it as an uncontrolled input in Form and passing isChecked means that we would have to control the component state in Form. We should instead move this logic to CheckboxWithLabel, so that the interface looks as that of an uncontrolled input.
  3. Calling React.forwardRef inline means that some props passed automatically from Form might not be defined when React runs its prop validation. We should call it in export default spreading all the props passed to the component, similar to what we do in AddressSearch

Why is this important?

We need to have the correct interface to work with Form.js

Solution

Described in each point above.

@luacmartins luacmartins self-assigned this Apr 18, 2022
@luacmartins luacmartins changed the title Rename onChange to onInputChange in CheckboxWithLabel Clean up CheckboxWithLabel refactor Apr 18, 2022
@luacmartins luacmartins added the Reviewing Has a PR in review label Apr 18, 2022
@melvin-bot melvin-bot bot closed this as completed Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant