TrimRows breaks undo

Tags: #<Tag:0x00007f8b19cbc2e8>

I cannot seem to understand what is going on when inserting a row into handsontable. I am trying to update the context menu based on the cell that is clicked. I am updating it beforeOnCellMouseDown by updateSettings. It seems to insert the correct row at first, but then when you click on the handsontable again, the row moves up however many trimmed rows I have (or at least I think). I made two jsfiddles to demonstrate my problem.

The first has the context menu updating onBeforeMouseDown: http://jsfiddle.net/mountaineerfan5/3258oa75/2/

The second does not update the context menu but still calls updateSettings inside the onBeforeMouseDown: http://jsfiddle.net/mountaineerfan5/3258oa75/4/

I thought it had to do with me updating the context menu in some way, but it still has the same behavior in the second jsfiddle, which makes me think it has something to do with updateSettings and the trimRows plugin.

Thanks for your help!

Hi @melissa

Can you tell me what exactly you would like to see in the context menu?

Then second demo in beforeOnCellMouseDown calls updateSettings inside the instance initialization (which won’t work) and the updateSettings is empty.

I wanted to make the context menu dynamic based on which row you right clicked on, but apparently I didn’t see the example on the handsontable website that actually did exactly that. So instead of using the beforeOnCellMouseDown hook to do it, I used the capability of contextMenu to do it by manually creating the menu.
Thanks for the information tho. I didn’t know that you couldn’t call updateSettings inside the instance initialization, but after I told you I looked at the documentation and it says it is supposed to be used after initialization.

Thanks again for the help!

happy to help @melissa

if you would need something else I’m here to help :slight_smile:

I did actually experience another issue with trimRows. If you remove a row and use ctrl+z to undo, it doesn’t undo the right row. If you remove the last row and then undo, it seems like its deleting a row. If you remove the 2nd row it and undo, it replaces it with one of the hidden rows. It has some odd behavior.
Here is a jsfiddle to demo it: http://jsfiddle.net/mountaineerfan5/3258oa75/6/

Thanks

Thank you for sharing @melissa

It is a bug. Even when we update to latest version 1.10.2 http://jsfiddle.net/handsoncode/6avL40fn/ we get the same result - a wrong row is added. When I deleted A7 I got A4 after an undo action.

Is there a fix planned for this issue? Is a workaround available?

Thanks.

Sorry @asokoloff

but I did not find any workaround.

Please track changes to this issue for updates https://github.com/handsontable/handsontable/issues/4781

Fixed offcially https://github.com/handsontable/handsontable/issues/4781

1 Like