handsontable icon indicating copy to clipboard operation
handsontable copied to clipboard

Undo produces error after any prop update (only with hyperformula)

Open olosegres opened this issue 2 years ago • 7 comments

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

  1. Enable forumals
  2. Make any prop to update after column creation
  3. Create column
  4. 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

olosegres avatar Jun 29 '22 07:06 olosegres

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.

adrianszymanski89 avatar Jul 01 '22 14:07 adrianszymanski89

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.

adrianszymanski89 avatar Jul 05 '22 11:07 adrianszymanski89

Hello ok, thank you

olosegres avatar Jul 05 '22 12:07 olosegres

Any updates? It is very annoying issue :(

olosegres avatar Sep 01 '22 09:09 olosegres

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.

adrianszymanski89 avatar Sep 02 '22 13:09 adrianszymanski89

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.

olosegres avatar Sep 09 '22 13:09 olosegres

Hi @olosegres

Thank you for that. I'll propose it to our development team, and then we decide. I'll update you.

adrianszymanski89 avatar Sep 12 '22 10:09 adrianszymanski89

Also effected by this bug. Please advise as to the internal progress.

aroth avatar Oct 26 '22 21:10 aroth

Note to myself: update topic

AMBudnik avatar Nov 03 '22 08:11 AMBudnik

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.

aninde avatar May 16 '23 10:05 aninde