[GH #9755] Error when using CellCoords from walkontable

Tags: #<Tag:0x00007f24a3b04450> #<Tag:0x00007f24a3b042e8>

Previously we were using Handsontable.wot.CellCoords in our project, for example in a callback function for the Comments plugin.

While upgrading to v12, we changed to using import CellCoords from 'handsontable/3rdparty/walkontable/src/cell/coords'; to fix Typescript error since wot seems to have been removed.

However, this results in a build error:

Module not found: Error: Package path ./3rdparty/walkontable/src/cell/coords is not exported from package /private/var/folders/n0/cw72x0014q52pdnnmdvjjdxc0000gp/T/broccoli-236l6nx7sN78ycz/cache-918-webpack_bundler_ember_auto_import_webpack/node_modules/handsontable (see exports field in /private/var/folders/n0/cw72x0014q52pdnnmdvjjdxc0000gp/T/broccoli-236l6nx7sN78ycz/cache-918-webpack_bundler_ember_auto_import_webpack/node_modules/handsontable/package.json)

I understand that walkontable is somehow private, but how I can work with types that the public API of handsontable uses from that package?

Hi @groeger

It appears that since we introduced modularization this method isn’t available anymore as an import and can’t be used.

Yes, but it is still exposed, e.g. as part of Selection in the ContextMenu plugin: https://github.com/handsontable/handsontable/blob/a1d16a69c2a5611aaae6c0752a3ea8ba0f166cdc/handsontable/types/plugins/contextMenu/contextMenu.d.ts#L18

So if I am dealing with Selections in my code, I have to import the type and that is when I get an error.

Hi @groeger

Would it be possible for you to send me a package with your project so I can investigate it? I want to make sure that we are on the same page here.

The project is quite big, so sending the entire project probably doesn’t make sense.

Here is one example:

I keep track of the current cell Selections when interacting with the ContextMenu:

cellSelections?: Handsontable.plugins.ContextMenu.Selection[]; 

Now I update this two ways:

via a callback on a menu item:

const items: Handsontable.plugins.ContextMenu.MenuConfig = {};
items.addComment = {
  name: 'add comment',
  callback(_key, selections, clickEvent) {
    if (clickEvent.button !== 0) {
      return; // only process left click
    cellSelections = selections;

and via setting the selection manually in case of some action:

onClickActionComment(row: number, col: number): void {
  cellSelections = [
    { start: new CellCoords(row, col), end: new CellCoords(row, col) },

In the second case I am using the CellCoords type imported from 'handsontable/3rdparty/walkontable/src/cell/coords';, as that is what is required by Handsontable.plugins.ContextMenu.Selection

Hi @groeger

Thank you for an explanation. I asked my colleague to help me with investigation here and we’ll get back to you after the weekend.

It looks like a problem in Handsontable - to be tracked in https://github.com/handsontable/handsontable/issues/9755.