6pac / SlickGrid

A lightning fast JavaScript grid/spreadsheet
https://github.com/6pac/SlickGrid/wiki
MIT License
1.82k stars 424 forks source link

fix: Editor.keyCaptureList is an array of numbers #1006

Closed AlexandrChazov closed 5 months ago

AlexandrChazov commented 5 months ago

The 'keyCaptureList' variable of the Editor class is an array of numbers.

ghiscoding commented 5 months ago

hmm are you sure about this? I actually don't know what that is for, I think @6pac added this (Ben do you have more info and can you do a review?). @AlexandrChazov if you do have more info of what that does then please add a description to the interface property because I didn't add one because I didn't know what it actually was for.

6pac commented 5 months ago

Yep, it should be an array of numbers. It allows codes that would normally be captured by the grid to be routed to the editor instead. For example, up and down might be used to traverse up and down a dropdown list where normally the grid would capture the keystrokes and move up or down a cell.

Sample code from my personal repo:

function SingleDropDownEditor(args) {
  var $input = null;
  var defaultValue;
  var self = this;
  var columnDataBundle = null;

  self.keyCaptureList = [Slick.keyCode.UP, Slick.keyCode.DOWN, Slick.keyCode.ENTER];

  self.OnIndexChangeEvent = function () {
    $input.focus();
  };
AlexandrChazov commented 5 months ago

Yes, @6pac is absolutely right. All the key codes like

Slick.keyCode.UP, Slick.keyCode.DOWN, Slick.keyCode.ENTER or import { keyCode } from "slickgrid"; keyCode.UP, keyCode.DOWN, keyCode.ENTER

are numbers and checks like

if (this.currentEditor.keyCaptureList.indexOf(e.which) > -1)

will always return false and traversing up and down a dropdown list will be captured by default Slickgrid hotkeys listeners

AlexandrChazov commented 5 months ago

@ghiscoding I've added the description.

ghiscoding commented 5 months ago

thanks