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

InspectorControls.ToggleControl onChange callback is passed whole event object as argument #4613

Closed
2 tasks
shramee opened this issue Jan 20, 2018 · 1 comment
Closed
2 tasks
Labels
[Type] Enhancement A suggestion for improvement.

Comments

@shramee
Copy link
Contributor

shramee commented Jan 20, 2018

Issue Overview

ToggleControl of block InspectorControls passes event object as parameter to onChange. Whereas other InspectorControls controls pass value of the control.

Steps to Reproduce (for bugs)

  1. Add ToggleControls and any other control e.g. RangeControl
  2. Make onChange callback console log the argument received.
  3. Compare ToggleControl and Range control outputs.

Expected Behavior

onChange callback should be passed event.target.checked as argument (Other controls pass event.target.value).

Current Behavior

Whole event object is passed which is not consistent with other controls.

Possible Solution

Well... Will try to do a PR... Idea is to do an anonymous function that calls onChange callback with checked property of the event target.

Screenshots / Video

image

Todos

  • Tests
  • Documentation
@jeffpaul jeffpaul added the [Type] Enhancement A suggestion for improvement. label Jan 26, 2018
@jordymeow
Copy link

I confirm this issue with Gutenberg 2.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants