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

Fix/switch double label click #2298

Closed
wants to merge 3 commits into from

Conversation

gyulus3
Copy link
Contributor

@gyulus3 gyulus3 commented May 21, 2024

What I did

This pull request fixes an issue where clicking the label of the lion-switch toggles the switch input twice.

Clicking on the label of a switch element and toggling the switch state is a native browser behaviour, so it automatically comes with any browser:

<label for="toggle">
   Label
   <input id="toggle" type="checkbox" switch>
</label>

Since the LionSwitch uses ChoiceInputMixin and its _toggleChecked function, the switch is toggled twice. In the PR I created I fixed this issue by not letting the native browser behavior to toggle the switch state.

Corresponding issue and the problem explanation: fixes #2284

Copy link

changeset-bot bot commented May 21, 2024

🦋 Changeset detected

Latest commit: 7994117

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@lion/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gerjanvangeest
Copy link
Member

Hi @gyulus3, sorry i was occupied with something else last few weeks.

I tried out this solution locally saw it working, but tried to add some tests. Got distracted and left it as is.
Normally i make sure all local changes are stashed aside, but somehow I pushed this fix along side with another PR:
https://github.com/ing-bank/lion/pull/2297/files#diff-5528dfc4a7b246f3718cdb6ed68e593ef46cf6046ae41114b5452c3e77e581a4

So this fix is already merged. I will close this PR but thanks for the fix! 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[LionSwitch]: Clicking on label tiggers checked-changed twice
2 participants