To reproduce, start typing into a cell on one device. Then type into another cell from another device.
On the first device, the whole state is refreshed and whatever was typed is lost.
It happens when the whole model is recreated here:
|
const newModel = Model.from_bytes(model.toBytes()); |
|
setModel(newModel); |
If I comment out these lines then the changes are not lost, but the state is also not refreshed until I move focus somewhere else.
Original application does not recreate the model, but redraws the whole component using setRedrawId hack:
https://github.com/ironcalc/IronCalc/blob/b9b3cb1628616a746fe7c06d41162df739eb79c0/webapp/IronCalc/src/components/Workbook/Workbook.tsx#L40-L42
If I add this setRedrawId to function App() and call it from setUpdateListener instead of recreating the model, there is the same problem, so it is likely a problem in the original app as well.
To reproduce, start typing into a cell on one device. Then type into another cell from another device.
On the first device, the whole state is refreshed and whatever was typed is lost.
It happens when the whole model is recreated here:
calc/src/App.tsx
Lines 97 to 98 in afe3213
If I comment out these lines then the changes are not lost, but the state is also not refreshed until I move focus somewhere else.
Original application does not recreate the model, but redraws the whole component using
setRedrawIdhack:https://github.com/ironcalc/IronCalc/blob/b9b3cb1628616a746fe7c06d41162df739eb79c0/webapp/IronCalc/src/components/Workbook/Workbook.tsx#L40-L42
If I add this
setRedrawIdtofunction App()and call it fromsetUpdateListenerinstead of recreating the model, there is the same problem, so it is likely a problem in the original app as well.