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 indeterminate checkbox edge cases #2458

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

ryubro
Copy link
Contributor

@ryubro ryubro commented Jan 24, 2025

What I did

There were a few problems in the LionCheckboxIndeterminate:

  1. When the element was connected, the last child was ignored because the _setOwnCheckedState() was called by form-element-register event before the same event was handled by the checkbox group which adds the element emitting the event to the formElements
  2. When it had disabled child and all the other children were checked, clicking the indeterminate checkbox didn't respond, because the checked state was false although, in practice, it was fully checked
  3. When the custom element's indeterminate property was true and the same property of the input node was also true, and clicking it should keep it indeterminated (like when one of the children is disabled and the others are mixed with checked and unchecked), the indeterminate property of the custom element doesn't change but the same property of the input node changes to false (seems like browser's default behavior) because no syncing could happen without the custome element's indeteminate property changing.

This PR fixes those issues.

Copy link

changeset-bot bot commented Jan 24, 2025

🦋 Changeset detected

Latest commit: 07467ef

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

fixes: #1967

@okadurin
Copy link
Collaborator

Could you add a test with a use case that covers __removeFromSubCheckboxes?

@okadurin
Copy link
Collaborator

When there is one of children checkboxes disabled checked and the other child checkbox is unchecked, the parent should be unchecked. Now it is checked

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.

3 participants