-
Notifications
You must be signed in to change notification settings - Fork 434
Warn about future changes to onChange callback [WIP] #1350
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
Warn about future changes to onChange callback [WIP] #1350
Conversation
adeb8d5
to
317ba96
Compare
f7eb975
to
bf80654
Compare
3636db4
to
f880825
Compare
* The audit showed that checkbox and inline edit's `onChange` are wrong (along with deprecated lookup's onChange, onBlur, onFocus, but we aren't updating Lookup). DataTable's `onChange` is also `(selectedArrayOfItems, event)`. I'm going think about that one a little more. * SLDS has moved their form components out from under the form folder, so a breaking change in event parameters was a good time to move the `checkbox` component out of the forms folder. That way, consumers can upgrade at their leisure--unless they are using the CommonJS named imports. * Right now, CommonJS and `components/forms/checkbox` users (that is everyone) will get the warning, but nothing will break. * Went ahead and converted checkbox to a ES6 class and removed a lodash function. * There was a comment in all the site-stories that mentioned `forms-checkbox` and that has been removed. * The first commit "Align event prop parameters" just adds from empty objects to a few components as the second parameter `data` object to existing event callbacks, just to guard from being `undefined` if accessed. This should be standardized. * If oldEventParameterOrder is true, a warning will fire. This will tell folks to change their path—if they are consuming the source code. The CommonJS named imports will just have to break at the next breaking change due to the parameter change, since you can’t change the path.
86248c4
to
e8c984e
Compare
…to event-parameter-standardize2
components/checkbox/check-props.js
Outdated
propAsString: 'onChange', | ||
propAsValue: props.onChange, | ||
}, | ||
'`components/forms/checkbox` is deprecated. `components/checkbox` should be used. When this path update is made `onChange` event parameters will change from `onChange(value, event, { value } to `onChange(event, { value }). Please update your event parameters when you change paths.` If you are using the CommonJS named import, `Checkbox` events will break at v1.0 and this warning will be present until then. Please review https://github.com/salesforce/design-system-react/releases when you upgrade.' |
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.
Minor: missing )
in onChange(value, event, { value } to ...
components/checkbox/check-props.js
Outdated
'`components/forms/checkbox` is deprecated. `components/checkbox` should be used. When this path update is made `onChange` event parameters will change from `onChange(value, event, { value } to `onChange(event, { value }). Please update your event parameters when you change paths.` If you are using the CommonJS named import, `Checkbox` events will break at v1.0 and this warning will be present until then. Please review https://github.com/salesforce/design-system-react/releases when you upgrade.' | ||
); | ||
|
||
if (props.variant === 'toggle' && props.indeterminate === true) { |
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.
Minor : === true
not necessary?
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.
Looks good to me!
…to event-parameter-standardize2 # Conflicts: # package.json
Fixes #273
Additional description
/forms
that are not deprecated, aliases have been added to make backwards compatible. The current code is NOT a breaking change, but it will update the documentation to promote use of/components/checkbox
instead.onChange
parameters are wrong (along with deprecated lookup's onChange, onBlur, onFocus, but we aren't updating Lookup).onChange
is also(selectedArrayOfItems, event)
. I'm going think about that one a little more. I'm thinkingonRowChange
oronRowSelect
would be the best backwards compatible option right now.checkbox
component out of the forms folder. That way, consumers can upgrade at their leisure--unless they are using the CommonJS named imports.components/forms/checkbox
users (that is everyone) will get the warning, but nothing will break.forms-checkbox
and that has been removed.data
object to existing event callbacks, just to guard from beingundefined
if accessed. This should be standardized.Deprecation warning for InlineEdit

Checkbox warning:

Pull Request Review checklist (do not remove)
npm run lint:fix
has been run and linting passes.components/component-docs.json
CI tests pass (npm test
).last-slds-markup-review
inpackage.json
and push.last-accessibility-review
, topackage.json
and push.npm run local-update
within locally cloned site repo to confirm the site will function correctly at the next release.