Skip to content

Commit 33225a7

Browse files
authored
fix(chip-group): Add existence checks (#7487)
## Summary Running into some error using Chip Group / Chip in React environment with programmatically populated Chips... ![Screenshot 2023-08-08 at 10 45 44 AM](https://github.com/Esri/calcite-design-system/assets/4733155/b8f1a301-b317-4d22-92f2-e4fd269d30a9) ![Screenshot 2023-08-08 at 10 33 17 AM](https://github.com/Esri/calcite-design-system/assets/4733155/b3c2e3dd-2253-4c43-8130-b8ca73bf0a1f) Adds check for existence of unfound element.
1 parent 864f7f7 commit 33225a7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/calcite-components/src/components/chip-group/chip-group.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ export class ChipGroup implements InteractiveComponent {
197197
private updateItems = (event?: Event): void => {
198198
const target = event ? (event.target as HTMLSlotElement) : this.slotRefEl;
199199
this.items = target
200-
.assignedElements({ flatten: true })
200+
?.assignedElements({ flatten: true })
201201
.filter((el) => el?.matches("calcite-chip")) as HTMLCalciteChipElement[];
202202

203-
this.items.forEach((el) => {
203+
this.items?.forEach((el) => {
204204
el.interactive = true;
205205
el.scale = this.scale;
206206
el.selectionMode = this.selectionMode;

0 commit comments

Comments
 (0)