Skip to content

Commit

Permalink
fix(core/select-item): check by undefined not by value (#1214)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Leroux <[email protected]>
  • Loading branch information
jul-lam and danielleroux authored Apr 15, 2024
1 parent 34b50ef commit 22a83d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-yaks-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siemens/ix": patch
---

fix(core/select-item): check by undefined not by value
2 changes: 1 addition & 1 deletion packages/core/src/components/select-item/select-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class SelectItem {
}

componentDidRender() {
if (!this.value) {
if (this.value === undefined || this.value === null) {
throw Error('ix-select-item must have a `value` property');
}
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ export class Select {
this.items.forEach((item) => {
item.selected = ids.some(
// Check can be removed if value is type of string in future releases
(i) => i === (item.value ? item.value.toString() : '')
(i) =>
i ===
(item.value !== undefined && item.value !== null
? item.value.toString()
: '')
);
});

Expand Down

0 comments on commit 22a83d9

Please sign in to comment.