Skip to content

Commit

Permalink
feat: switch darkmode inside init
Browse files Browse the repository at this point in the history
  • Loading branch information
zewa666 committed Sep 13, 2024
1 parent aec04ed commit 908e7aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/common/src/core/__tests__/slickGrid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,15 @@ describe('SlickGrid core file', () => {

expect(rowSelectSpy).toHaveBeenCalled();
});

it('should clear previous selection model when calling setSelectionModel() with a different model', () => {
const cellSelectionModel = new SlickCellSelectionModel();

grid = new SlickGrid<any, Column>(container, [], columns, { ...defaultOptions, darkMode: true });
cellSelectionModel.init(grid);

expect(cellSelectionModel.cellRangeSelector.addonOptions.selectionCss).toBe('2px solid white');

Check failure on line 1169 in packages/common/src/core/__tests__/slickGrid.spec.ts

View workflow job for this annotation

GitHub Actions / ubuntu-latest / Node 20

packages/common/src/core/__tests__/slickGrid.spec.ts > SlickGrid core file > plugins > should clear previous selection model when calling setSelectionModel() with a different model

AssertionError: expected { border: '2px solid white' } to be '2px solid white' // Object.is equality - Expected: "2px solid white" + Received: Object { "border": "2px solid white", } ❯ packages/common/src/core/__tests__/slickGrid.spec.ts:1169:78
});
});

describe('Node Getters', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/common/src/extensions/slickCellSelectionModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class SlickCellSelectionModel implements SelectionModel {
this._eventHandler = new SlickEventHandler();

this._selector = (options === undefined || options.cellRangeSelector === undefined)
? new SlickCellRangeSelector({ selectionCss: { border: `2px solid ${this._grid.getOptions().darkMode ? "white" : "black"}` } as CSSStyleDeclaration })
? new SlickCellRangeSelector({ selectionCss: { border: '2px solid black' } as CSSStyleDeclaration })
: options.cellRangeSelector;

this._addonOptions = options;
Expand All @@ -52,6 +52,10 @@ export class SlickCellSelectionModel implements SelectionModel {

init(grid: SlickGrid): void {
this._grid = grid;
if (this._addonOptions === undefined || this._addonOptions.cellRangeSelector === undefined) {
this._selector = new SlickCellRangeSelector({ selectionCss: { border: `2px solid ${this._grid.getOptions().darkMode ? "white" : "black"}` } as CSSStyleDeclaration })
}

if (grid.hasDataView()) {
this._dataView = grid.getData<CustomDataView | SlickDataView>();
}
Expand Down

0 comments on commit 908e7aa

Please sign in to comment.