From f25eeec7a277d4b915d1423f12e688ad8ac98e7c Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Wed, 19 Jul 2023 21:43:47 -0400 Subject: [PATCH] fix(plugins): RowMoveManager shouldn't add cssClass when not usable (#1044) * fix(plugins): RowMoveManager shouldn't add cssClass when not usable - when `usabilityOverride` returns false on some rows, we shouldn't add the `cssClass` on the parent div --- .../src/extensions/__tests__/slickRowMoveManager.spec.ts | 6 ++---- packages/common/src/extensions/slickRowMoveManager.ts | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/common/src/extensions/__tests__/slickRowMoveManager.spec.ts b/packages/common/src/extensions/__tests__/slickRowMoveManager.spec.ts index 6b433ec3f..7df6f47f5 100644 --- a/packages/common/src/extensions/__tests__/slickRowMoveManager.spec.ts +++ b/packages/common/src/extensions/__tests__/slickRowMoveManager.spec.ts @@ -139,7 +139,6 @@ describe('SlickRowMoveManager Plugin', () => { it('should call the "create" method and expect plugin to be created with checkbox column to be created at position 0 when using default', () => { const pubSubSpy = jest.spyOn(pubSubServiceStub, 'publish'); const rowMoveColumnMock = { - cssClass: 'slick-row-move-column', excludeFromColumnPicker: true, excludeFromExport: true, excludeFromGridMenu: true, @@ -188,7 +187,6 @@ describe('SlickRowMoveManager Plugin', () => { expect(plugin).toBeTruthy(); expect(mockColumns[1]).toEqual({ behavior: 'selectAndMove', - cssClass: 'slick-row-move-column', excludeFromColumnPicker: true, excludeFromExport: true, excludeFromGridMenu: true, @@ -227,7 +225,7 @@ describe('SlickRowMoveManager Plugin', () => { const output = plugin.getColumnDefinition().formatter!(0, 0, null, { id: '_move', field: '' } as Column, { firstName: 'John', lastName: 'Doe', age: 33 }, gridStub); expect(plugin).toBeTruthy(); - expect(output).toEqual({ addClasses: 'cell-reorder dnd', text: '' }); + expect(output).toEqual({ addClasses: 'cell-reorder dnd slick-row-move-column', text: '' }); }); it('should process the "checkboxSelectionFormatter" and expect necessary Formatter to return regular formatter when usabilityOverride is not a function', () => { @@ -236,7 +234,7 @@ describe('SlickRowMoveManager Plugin', () => { const output = plugin.getColumnDefinition().formatter!(0, 0, null, { id: '_move', field: '' } as Column, { firstName: 'John', lastName: 'Doe', age: 33 }, gridStub); expect(plugin).toBeTruthy(); - expect(output).toEqual({ addClasses: 'cell-reorder dnd', text: '' }); + expect(output).toEqual({ addClasses: 'cell-reorder dnd slick-row-move-column', text: '' }); }); it('should create the plugin and trigger "dragInit" event and expect "stopImmediatePropagation" to be called', () => { diff --git a/packages/common/src/extensions/slickRowMoveManager.ts b/packages/common/src/extensions/slickRowMoveManager.ts index d686a92dc..b263a8989 100644 --- a/packages/common/src/extensions/slickRowMoveManager.ts +++ b/packages/common/src/extensions/slickRowMoveManager.ts @@ -133,7 +133,6 @@ export class SlickRowMoveManager { id: columnId, name: '', behavior: 'selectAndMove', - cssClass: this._addonOptions.cssClass, excludeFromExport: true, excludeFromColumnPicker: true, excludeFromGridMenu: true, @@ -321,7 +320,7 @@ export class SlickRowMoveManager { if (!this.checkUsabilityOverride(row, dataContext, grid)) { return ''; } else { - return { addClasses: 'cell-reorder dnd', text: '' }; + return { addClasses: `cell-reorder dnd ${this._addonOptions.cssClass || ''}`, text: '' }; } } } \ No newline at end of file