handsontable
handsontable copied to clipboard
Undo produces error after any prop update (only with hyperformula)
Description
Hello, at Actonic we use this plugin with hyperformula. Recently has been moved to react version and stumbled upon a bug.
Undo operation produces error There is no operation to undo
if any prop has been updated right after historical action.
CrudOperations.undo
https://wxvqlc.csb.app/node_modules/hyperformula/es/CrudOperations.js:501:15
HyperFormula.undo
https://wxvqlc.csb.app/node_modules/hyperformula/es/HyperFormula.js:325:28
Core.eval
https://wxvqlc.csb.app/node_modules/handsontable/plugins/formulas/formulas.mjs:443:23
fastCall
https://wxvqlc.csb.app/node_modules/handsontable/helpers/function.mjs:177:17
Hooks.run
https://wxvqlc.csb.app/node_modules/handsontable/pluginHooks.mjs:194:59
Core.runHooks
https://wxvqlc.csb.app/node_modules/handsontable/core.mjs:2105:46
UndoRedo.undo
From what I understand, it clears Hyperformula's internal crudOperations after any update of the HotTable. So the undoRedo stack for hansontable and hyperformula is out of sync (redo is available in handsontable but doesn't work due to hyperformula)
Steps to reproduce
- Enable forumals
- Make any prop to update after column creation
- Create column
- Press Command+Z
Demo
https://codesandbox.io/s/upbeat-bush-wxvqlc
Your environment
- React wrapper version: 18
- Handsontable version: 12.1
- Browser name and version: Chrome 103, Firefox
- Operating system: macos, linux
Hi @olosegres
Thank you for reporting this. It looks to me like the issue is connected to the state manager, which is weird as we addressed that problem in the latest releases. I'll have to dig a little bit deeper to see what's exactly going on here and get back to you after the weekend.
Hi @olosegres
I have investigated your issue further, but I didn't find related to the configuration, so the problem must lie deeper. I added needed labels so our developers will be able to work on that when this issue will appear on our roadmap.
Hello ok, thank you
Any updates? It is very annoying issue :(
Hi @olosegres
We re-checked this issue as we are currently working on improving our React experience, and we discovered that it lies within our React wrapper. To be more precise, it's occurring because Handsontable is re-initialized each time when the props are updated. We will keep working on improving our React wrapper, so I'll update you when we get to that point.
Hi @adrianszymanski89
Ok, thanks.
We could't find a workaround for this bug in some cases, f.e. when updating objects (mergeCells prop).
So we had to fork hyperformula and made little changes. https://bitbucket.org/actonic/hyperformula/commits/b4119ce2ba0c0642cc4f4e9c1755dedabe6c2fca
I do not know is it right way to fix this problem. But it seems like plugin shouldn't treat its own empty undoRedo stack as error.
Let us know is it valid fix and you would like to merge such PR.
Hi @olosegres
Thank you for that. I'll propose it to our development team, and then we decide. I'll update you.
Also effected by this bug. Please advise as to the internal progress.
Note to myself: update topic
Hi, @olosegres. I'm currently testing the upcoming version 12.4.0, which addresses the reported issue. I have thoroughly examined the demo using the upgraded versions of Handsontable (12.4.0) and HyperFormula (v2.4.0), and I can confirm that there are no problems observed when undoing column insertions. To validate this, I have prepared a working demo for your reference.