reactgrid icon indicating copy to clipboard operation
reactgrid copied to clipboard

Dropdown cell not updating selected value

Open maberalc opened this issue 2 years ago • 1 comments

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 image *"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.

maberalc avatar Jun 22 '22 11:06 maberalc

Yeah, I have run into this problem me too, When selecting a value from the dropdown the value is not updated in onCellsChanged handler

kanounfoued avatar Aug 30 '22 09:08 kanounfoued

@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.

mathdevelop avatar Nov 07 '22 16:11 mathdevelop

I managed to find ways in this closed Issue: https://github.com/silevis/reactgrid/issues/76 Thanks!!

mathdevelop avatar Nov 07 '22 17:11 mathdevelop

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 ?

samuelhsin avatar Nov 22 '22 06:11 samuelhsin

I found if add key string into Select component props can resolve copy/paste render issue. image

samuelhsin avatar Nov 22 '22 07:11 samuelhsin

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 ).

DLowHP avatar Jul 27 '23 09:07 DLowHP