8.0.0 migration getCellMeta throws error unsigned number

Tags: #<Tag:0x00007f8b1d759040>

The following custom context menu option worked fine in version 7.4.2 to determine if the selected column was a date type. It now throws an Uncaught Error in 8.0.0.

    'filterByDate': {
      name: 'Filter By Date',
      hidden: function () {
        // do not display option if column header not selected and not a
        // date type
        var selection = this.getSelected()[0];

        if (!this.selection.isSelectedByColumnHeader() ||
            this.getCellMeta(selection[0], selection[1]).type != 'date' ||
            hasFilter()) {
          return true;
        }
      },
      callback: function () {
        $('#date-filter-popup').modal('toggle');
      }
    },

This is actually mentioned in our migration guide (https://handsontable.com/docs/8.0.0/tutorial-migration-guide.html) in section Selection range have negative indexes. Starting with version 8, selection[0] will have a negative index to include selected header. If you need data only you will have to normalize the selection Math.max(0, indexIncludingHeader) or, in your example, you’re always interested in first row so you can hardcode it.

1 Like

Thank You