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

docs(components/toggle-control): clarify that onChange is not required #16090

Merged

Conversation

dsifford
Copy link
Contributor

Description

Per discussion in Slack with @gziolo, this adjustment to the docs reflects the fact that onChange is not required if the user intends the component to be an "uncontrolled" component.

Let me know if you have any further questions/comments.

How has this been tested?

N/A

Screenshots

N/A

Types of changes

Docs

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@Soean
Copy link
Member

Soean commented Jun 11, 2019

TextControl, SelectControl, RangeControl, etc. require onChange. If we change it in one component, we should adjust it for all.

@dsifford
Copy link
Contributor Author

@Soean I'm cool with keeping required, but if that's the case, then we should probably remove the conditional here...

onChange( event ) {
if ( this.props.onChange ) {
this.props.onChange( event.target.checked );
}
}

Because if it is indeed required, the code should throw an error if it's not provided.

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

This one is complex, the best approach would be to change to required and be consistent with other components, but the fact is that it is not required now and requiring it is a breaking change, we may make some plugin crash, but these plugins did not follow the docs which referred the prop was required. I'm not sure what's the best path here, I guess we will need to break consistency in order to not break back compatibility. Any on this @youknowriad?

@youknowriad
Copy link
Contributor

Another option would be to make all it not required in all the other components to keep consistency but Tbh I don't think we had the intention to support "uncontrolled" components. I don't think anyone would be using uncontrolled component here.

@aduth
Copy link
Member

aduth commented Jun 25, 2019

If it's documented as being required, I don't think it needs to be considered as a breaking change to remove the condition which guards against its falsiness.

@jorgefilipecosta
Copy link
Member

If it's documented as being required, I don't think it needs to be considered as a breaking change to remove the condition which guards against its falsiness.

Hi @aduth, just to confirm you would like to keep the onChange as required and you think we should remove the condition that guards against an undefined value?
cc: @jorgefilipecosta to keep track of the updates.

@aduth
Copy link
Member

aduth commented Dec 17, 2019

If it's documented as being required, I don't think it needs to be considered as a breaking change to remove the condition which guards against its falsiness.

Hi @aduth, just to confirm you would like to keep the onChange as required and you think we should remove the condition that guards against an undefined value?

Yes, this is what I mean.

@mkaz mkaz added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Apr 13, 2020
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Based on the discussion it’s fine to merge

@gziolo gziolo merged commit e24ac3e into WordPress:master Nov 14, 2020
@github-actions github-actions bot added this to the Gutenberg 9.4 milestone Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants