fix(choice-group): handle boolean values in multipleChoice checkbox groups#2672
fix(choice-group): handle boolean values in multipleChoice checkbox groups#2672gouthamx67 wants to merge 2 commits intoing-bank:masterfrom
Conversation
🦋 Changeset detectedLatest commit: 842c9fd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Hi @gouthamx67 Thank you for contribution! May I ask you to revert all the unrelated changes like those outside of packages/ui/components/form-core/src/choice-group/ChoiceGroupMixin.js file. If an empty array is the problem you could move |
|
Hi! Thanks for the review and the clear guidance 🙏 I’ve reverted all unrelated changes and limited the update to packages/ui/components/form-core/src/choice-group/ChoiceGroupMixin.js. I also moved // @ts-nocheck to just above the empty array as suggested, and ran npm run changeset to generate a patch changelog for @lion/ui. I’m new to open source, so apologies for any inconvenience caused earlier , really appreciate the feedback and patience. Please let me know if anything else needs adjustment! |
|
6f450d1 to
19cce90
Compare
|
Thanks for your patience and guidance — still learning my way around Git and PR hygiene, and this was a great learning experience for me. I’ve cleaned up the PR so only the intended files are changed and signed the CLA. Please let me know if anything else is needed |
|
|
hey , Ive updated the logic to allow single string values for multipleChoice and fixed the linting/type issues as requested :) |
|
What was done
In the _setCheckedElements method of ChoiceGroupMixin.js, a small safeguard was added to handle cases where multipleChoice is enabled but the incoming modelValue is not an array.
In some situations (such as when navigating back to a page), modelValue could be a boolean. Since the existing logic assumes an array and calls .includes(), this caused a runtime error.
To fix this, the value is now first normalized:
If it’s already an array, it’s used as-is
If it’s not an array, it’s treated as an empty array
Both .includes() checks were updated to use this normalized value, ensuring the logic remains safe and predictable.