Skip to content

feat: ionChange event: determine whether it by user interaction #19651

Closed
@tricki

Description

@tricki

Feature Request

Ionic version:

[x] 4.10

Describe the Feature Request
Add a way to figure out if the checked value of ion-toggle was changed by user interaction or programatically.

Describe Preferred Solution
Add a new property to the event object or the detail property.

Describe Alternatives

  1. Add a new event (e.g. ionUserChange) that only fires on user interaction.
  2. Add the original event to detail.

All of these solutions could be expanded to other components.

Related Code
Same request: #17123

Additional Context
My use case: I have a dark mode toggle and on ionChange I save the user's preference. Until the user manually sets the toggle I use the OS setting (which I get using window.matchMedia('(prefers-color-scheme: dark)')). When the OS setting changes the toggle should change as well. But this saves the new value and no longer checks the OS preference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions