reactgrid
reactgrid copied to clipboard
Dropdown cell not updating selected value
Describe the bug Dropdown cell doesn't update when selected id changes from state.
Current behavior I've made a component that contains a grid. One of the columns is dropdown. This component receives an array of object from props and converts it to rows. The problem is that when props change, and selected value from that cell is changed, the cell stays with the same label selected.
Expected behavior When selected value changes programatically it should update selected label.
Screenshots or gifs
*"resource" comes from mapping props array
Cell 0 which is the same id than selected value, but in text cell, is updating correctly. Problem comes with dropdown cell.
Your environment details
- Device: Desktop
- OS: Windows
- Browser: Chrome
Am I missing something? Or I just found a little bug?
Thanks for your help in advance.
Yeah, I have run into this problem me too, When selecting a value from the dropdown the value is not updated in onCellsChanged handler
@maberalc Could you share how to generate the 'rowOpen' to open the Dropdown? @czerwiukk Is there another way to open Dropdown? If so, could you help me, I'm not able to open a Dropdown at a time.
I managed to find ways in this closed Issue: https://github.com/silevis/reactgrid/issues/76 Thanks!!
I found when copy dropdown value and paste to another cell, the cell value changed but display was not be rerender. Same demo can illustrate this issue. https://codesandbox.io/s/silevis-reactgrid-working-dropdown-example-ow9j2c?file=/src/App.tsx:1179-1270
Could we get the cell template instance to force render ?
I found if add key string into Select component props can resolve copy/paste render issue.
I took a look at the issue and it seems like the underlying Select component didn't update it's value when just the defaultValue
changed and instead used it only on the initial render. To resolve this I made the value
controlled (see: #195 ).