-
Notifications
You must be signed in to change notification settings - Fork 66
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
Allow defaultChecked to be used in Checkbox #2600
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@leafygreen-ui/checkbox': patch | ||
--- | ||
|
||
Allow defaultChecked to be used in Checkbox |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ function Checkbox({ | |
id: idProp, | ||
indeterminate: indeterminateProp, | ||
label = '', | ||
defaultChecked = false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe other components use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have a strong opinion; I'll defer to @TheSonOfThomp since you regularly work in this repo. |
||
onClick: onClickProp, | ||
onChange: onChangeProp, | ||
name, | ||
|
@@ -59,7 +60,7 @@ function Checkbox({ | |
const { darkMode, theme } = useDarkMode(darkModeProp); | ||
const baseFontSize = useUpdatedBaseFontSize(baseFontSizeProp); | ||
|
||
const [checked, setChecked] = React.useState(false); | ||
const [checked, setChecked] = React.useState(defaultChecked); | ||
const isChecked = React.useMemo( | ||
() => (checkedProp != null ? checkedProp : checked), | ||
[checkedProp, checked], | ||
|
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 think this would be a
minor
change, since it adds a featureThere 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.
Okay!! Should I change it manually to
minor
in this file or should I run the script again to change it?