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

[LionSwitch]: Clicking on label tiggers checked-changed twice #2284

Open
gyulus3 opened this issue May 15, 2024 · 3 comments · May be fixed by #2298
Open

[LionSwitch]: Clicking on label tiggers checked-changed twice #2284

gyulus3 opened this issue May 15, 2024 · 3 comments · May be fixed by #2298

Comments

@gyulus3
Copy link
Contributor

gyulus3 commented May 15, 2024

Expected behavior

Clicking on the label changes the checked value of the switch.

Actual Behavior

Clicking on the label doesn't change the checked value of the switch, because event checked-changed is triggered twice, so it changes back to the original value.

@gerjanvangeest
Copy link
Member

The expected behavior is that it only should focus the switch.

But indeed ideally it should not send the checked-changed event at all.

@gyulus3 are you willing to dive into this and and create a fix PR?

@gyulus3
Copy link
Contributor Author

gyulus3 commented May 15, 2024

In my opinion and as I see in the implementation clicking on the label was intended to trigger the switch and change the checked value, but since it triggers the checked-change twice it does not do anything visually (switching the checked value to opposite and back).

I've already dived into it and trying to solve the issue. The component uses _preventDuplicateLabelClick from the ChoiceInputMixin. The same issue was present once in other components, but this function does not solve the issue in this case. As soon as I find a solution I create a fix PR.

@gerjanvangeest
Copy link
Member

@gyulus3 you are indeed correct. I answered without double checking the code. And we even have a test saying so:

it('clicking the label should toggle the checked state', async () => {

./packages/ui/components/switch/test/lion-switch.test.js#L42

So only the duplicate clicking should be fixed.

@gyulus3 gyulus3 linked a pull request May 21, 2024 that will close this issue
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 a pull request may close this issue.

2 participants