Skip to content

Feat ion toggle toggle event#19509

Closed
mahnuh wants to merge 3 commits into
ionic-team:mainfrom
mahnuh:feat-ion-toggle-toggle-event
Closed

Feat ion toggle toggle event#19509
mahnuh wants to merge 3 commits into
ionic-team:mainfrom
mahnuh:feat-ion-toggle-toggle-event

Conversation

@mahnuh

@mahnuh mahnuh commented Oct 1, 2019

Copy link
Copy Markdown

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

The ionChange event will be emitted as soon as the toggle's value changes, whether that is because the toggle is being toggled manually or the value changes otherwise, programatically for example. At the moment from the ionChange event there is no way to determine if the value change happened manually or automatically.
This is basically the same issue as mentioned in PR #19097 for ion-checkbox.

What is the new behavior?

This PR adds the ionToggle event which is only emitted when the toggle actually is being toggled by the user.

Does this introduce a breaking change?

  • Yes
  • No

Other information

--

@ionitron-bot ionitron-bot Bot added package: angular @ionic/angular package package: core @ionic/core package labels Oct 1, 2019
@manucorporat

Copy link
Copy Markdown
Contributor

I am not convinced about adding random APIs across inputs, we need to solve the problem for all inputs at once, and ship a consistent API for all components.

Maybe it could be a prop of ionChange itself, like "userInteraction" or "trigger"

@mahnuh

mahnuh commented Oct 2, 2019

Copy link
Copy Markdown
Author

This actually would be great and solve so many problems. Should I open an issue for that?

@liamdebeasi

Copy link
Copy Markdown
Contributor

@manucorporat I'm wondering if the "trigger" would be good to add to all events for interactive components? I could see this being useful on ion-checkbox or ion-radio as well.

@tricki

tricki commented Oct 14, 2019

Copy link
Copy Markdown

This event should probably also be emitted when the state is changed by dragging.

This might also be useful for ion-input, in which case "trigger" might not be the ideal name.

@liamdebeasi

Copy link
Copy Markdown
Contributor

Thanks for the PR! We appreciate the work you put into creating this. After discussing with the team, we have decided not to accept this PR.

This is similar to #20106. We feel it would be best to provide a way to differentiate between programmatic and user generated ionChange events to avoid the issue described in the initial post here.

I am going to close this PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants