[GH #5727] ContextMenu callback - The "runHooks" method cannot be called

Tags: #<Tag:0x00007fa98d577018> #<Tag:0x00007fa98d576e60>

I’m calling updateSettings for fixed rows or columns via a context menu custom item. (I also have some custom inputs and check boxes to do the same thing that do not suffer from this error).

See: https://jsfiddle.net/stigmund/zgch83qu/3/ (open dev tools, right click and fix a row or column, see the error)

Although the code runs fine it generates the error:
The “runHooks” method cannot be called because this Handsontable instance has been destroyed”.

The exact code that causes the problem (AFTER my function has run):

hotInstance.updateSettings({
  fixedColumnsLeft: colsToFix,
  fixedRowsTop: rowsToFix
});

After playing about in the browser debug tools, it looks to be due to a context menu callback to to instance.runHooks(‘afterOnCellMouseUp’, event, coords, TD);.
This is further supported by the fact that using the keyboard to navigate the context menu and hit “enter” on the same item does not throw the same error.

NOTE: wrapping the problem code in a setTimeout will also not throw the error - its as if the table is destroying and re-instantiating itself in the middle of an execution and by the time the timeout runs, its re-instantiated - I don’t know why it would set all hooks to “postMortem()” - I obviously don’t understand the inner workings of HandsOnTable but i would have assumed my table needs to persist rather than re-init itself constantly.

Like i said, my code runs and works (or at least it appears to, i don’t know if there will be issues as i try to add more complexity), but i’d rather not have the console fill up with these messages. Is there a “more correct” way to do what i’m trying to do that wont throw this error? (the timeout is very much a work around and not desired).

To summarise: calling table.updateSettings (at least with row and column fixing) from a context menu click will always throw the error “The “runHooks” method cannot be called because this Handsontable instance has been destroyed”.
Am I using HandsOnTable correctly in this regard?

Cheers,
Steve.

Hey Steve,

I have replicated the demo I but I have one question here

  • what’s the exact goal? Is it adding className to a fixed column? (please correct me if I’m wrong)

The goal is to be able to click “column fix” and “row fix” options in the context menu WITHOUT receiving the error.

(the class names are just something I’ve added to make the column/row fix physically visible - you can ignore this it should have no impact on the replication of the bug (bug occurs with or without this extended css)).

Regards,
Steve.

Yes, but then what is the goal for the button. I will share some more details to make it more clear.

47

fix all rows up to this row
Fixed rows with the selected row, so if we select A2 (2 row) it fixes index 0,1. But what happens if there already A3 (index 0) fixed? Then the questions might be - do you allow to change row positions or do you want to allow fixing non-consecutive rows?
The same questions are left to fix all columns up to this column

Unfix rows
do you want to enable these options to all the cells in the table or unfix only selected rows?
The same questions refers to unfix columns

I think you are reading too much into my demo. I am successfully able to fix/unfix columns and rows - as the demo shows, it works. This is not the issue.

The issue is when i do this from the context menu item via “clicking” you get the error:
The “runHooks” method cannot be called because this Handsontable instance has been destroyed

Generally speaking, throwing an error like this is a warning to the developer that they are doing something wrong.

I’m just trying to polish up my code and get a better understanding of how to use Handsontable.

Ideally I’d not like to see errors in the console - things like this can be red herrings to our support staff if a bug came in relating to a table feature that we have customised.

If this is purely just an “FYI” error it would be nice to be able to disable it (debug: false does not prevent it).

I guess that the issue might be related to this report https://github.com/handsontable/handsontable/issues/5727
I have simplified the demo to minimum and we stil get the same call https://jsfiddle.net/z7fw8bjc/

I will update you once we have the above issue solved

Interesting read.

Although i don’t think i’m experiencing the exact same issue (well, if there is a leak, i guess everyone is), it looks like the issue I’ve reported is as a result of the “cleanup” to prevent the leak - or I’ve misunderstood it completely :upside_down_face:

Regardless, thanks for the update and the link - i’ll keep my eyes open for any progress and just make a note in my code that it’s not an issue to worry about right now.

Cheers,
Steve.