Skip to content

Commit

Permalink
fix(core): Editor.keyCaptureList is an array of numbers (#1458)
Browse files Browse the repository at this point in the history
* fix(core): Editor.keyCaptureList is an array of numbers
  • Loading branch information
ghiscoding committed Apr 5, 2024
1 parent 7563126 commit 62a686e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/common/src/core/__tests__/slickGrid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4346,7 +4346,7 @@ describe('SlickGrid core file', () => {

expect(grid.getCellFromEvent(null as any)).toBeNull();
expect(grid.getCellFromEvent(new SlickEventData(null))).toBeNull();
})
});

it('should return null when clicked cell is not a slick-cell closest ancestor', () => {
grid = new SlickGrid<any, Column>(container, data, columns, { ...defaultOptions, enableCellNavigation: true });
Expand Down Expand Up @@ -5568,7 +5568,7 @@ describe('SlickGrid core file', () => {
grid = new SlickGrid<any, Column>(container, items, columns, { ...defaultOptions, enableCellNavigation: true, editable: true });
grid.setActiveCell(0, 1);
grid.editActiveCell(InputEditor as any, true);
(InputEditor.prototype as any).keyCaptureList = ['1', '2', '3'];
(InputEditor.prototype as any).keyCaptureList = [1, 2, 3];
const onKeyDownSpy = jest.spyOn(grid.onKeyDown, 'notify');
const event = new CustomEvent('keydown');
const stopPropagationSpy = jest.spyOn(event, 'stopPropagation');
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/core/slickGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4761,7 +4761,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
if (!e.shiftKey && !e.altKey) {
// editor may specify an array of keys to bubble
if (this._options.editable && this.currentEditor?.keyCaptureList) {
if (this.currentEditor.keyCaptureList.indexOf(String(e.which)) > -1) {
if (this.currentEditor.keyCaptureList.indexOf(e.which) > -1) {
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/interfaces/editor.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface Editor {
/** is the Editor disabled when we first open it? This could happen when we use "collectionAsync" and we wait for the "collection" to be filled before enabling the Editor. */
disabled?: boolean;

/** editor may specify an array of keys to bubble */
keyCaptureList?: string;
/** List of key codes, which will not be captured by default slickgrid hotkeys listeners */
keyCaptureList?: number[];

/** Initialize the Editor */
init: (args?: EditorArguments) => void;
Expand Down

0 comments on commit 62a686e

Please sign in to comment.