Skip to content

Commit

Permalink
fix(plugins): RowMoveManager shouldn't add cssClass when not usable (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
ghiscoding committed Jul 20, 2023
1 parent a6d194a commit f25eeec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/common/src/extensions/slickRowMoveManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export class SlickRowMoveManager {
id: columnId,
name: '',
behavior: 'selectAndMove',
cssClass: this._addonOptions.cssClass,
excludeFromExport: true,
excludeFromColumnPicker: true,
excludeFromGridMenu: true,
Expand Down Expand Up @@ -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: '' };
}
}
}

0 comments on commit f25eeec

Please sign in to comment.