siemens / ix

Siemens Industrial Experience is a design system for designers and developers, to consistently create the perfect digital experience for industrial software products.
https://ix.siemens.io/
MIT License
207 stars 67 forks source link

[React] IxSelect not showing initial selected value #1554

Closed OG84 closed 1 week ago

OG84 commented 2 weeks ago

Prerequisites

What happened?

When using <IxSelect> with dynamically populated nested <IxSelectItem>'s, the initial value (using value prop) is not selected correctly.

When using the deprecated selectedIndices prop, the initial value is shown correctly.

This must have something to do with the change detection when IxSelectItems are changed dynamically after the parent IxSelect has been rendered.

This bug only occurs for dynamic IxSelectItems. For static hard coded values it is working fine.

Please see my stackblitz.

Edit: Seems like when setting the value prop AFTER the items have been initialized it is working. (e.g. setSelectedValue('2') inside the callback, see example code)

What type of frontend framework are you seeing the problem on?

React

Which version of iX do you use?

v2.5.0

Code to produce this issue.

https://stackblitz.com/edit/react-hsbjhb?file=src%2FApp.js
OG84 commented 2 weeks ago

ok so it seems like the same bug is present with selectedIndizes. But due to the fact that I'm supplying a new array instance on each render, in my example it looks like it's working. Without wrapping the selectedIndizes in a new array each time, the same problem occurs.

matthiashader commented 1 week ago

Closes via #1548.