Skip to content

Commit

Permalink
Revert "fix: redraw all open row details whenever the grid is re-rend…
Browse files Browse the repository at this point in the history
…ered (#1…"

This reverts commit 4ecb439.
  • Loading branch information
ghiscoding authored Oct 19, 2024
1 parent 9e9c9b9 commit f4d0550
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const gridStub = {
registerPlugin: jest.fn(),
setSelectionModel: jest.fn(),
sanitizeHtmlString: (s: string) => s,
onRendered: new SlickEvent(),
onColumnsReordered: new SlickEvent(),
onSelectedRowsChanged: new SlickEvent(),
onSort: new SlickEvent(),
} as unknown as SlickGrid;
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('SlickRowDetailView', () => {
columnsMock = [{ id: 'field1', field: 'field1', width: 100, cssClass: 'red' }];
jest.spyOn(gridStub, 'getOptions').mockReturnValue(gridOptionsMock);
jest.clearAllMocks();
gridStub.onRendered = new SlickEvent();
gridStub.onColumnsReordered = new SlickEvent();
gridStub.onSort = new SlickEvent();
});

Expand Down Expand Up @@ -391,7 +391,7 @@ describe('SlickRowDetailView', () => {
});
});

it('should call Aurelia Util "createAureliaViewModelAddToSlot" when grid "onRendered" is triggered', (done) => {
it('should call Aurelia Util "createAureliaViewModelAddToSlot" when grid "onColumnsReordered" is triggered', (done) => {
const mockColumn = { id: 'field1', field: 'field1', width: 100, cssClass: 'red', __collapsed: true };
const handlerSpy = jest.spyOn(plugin.eventHandler, 'subscribe');
// @ts-ignore:2345
Expand All @@ -401,7 +401,7 @@ describe('SlickRowDetailView', () => {
plugin.onBeforeRowDetailToggle = new SlickEvent();
plugin.register();
plugin.eventHandler.subscribe(plugin.onBeforeRowDetailToggle, () => {
gridStub.onRendered.notify({ impactedColumns: [mockColumn] } as any, new SlickEventData(), gridStub);
gridStub.onColumnsReordered.notify({ impactedColumns: [mockColumn] } as any, new SlickEventData(), gridStub);
expect(appendSpy).toHaveBeenCalledWith(
ExampleLoader,
expect.objectContaining({ model: mockColumn, addon: expect.anything(), grid: gridStub }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
// --
// hook some events needed by the Plugin itself

// redraw anytime the grid is re-rendered
this.eventHandler.subscribe(this._grid.onRendered, this.redrawAllViewSlots.bind(this));
// we need to redraw the open detail views if we change column position (column reorder)
this._eventHandler.subscribe(this._grid.onColumnsReordered, this.redrawAllViewSlots.bind(this));

// on row selection changed, we also need to redraw
if (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector) {
Expand All @@ -208,7 +208,8 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
// on filter changed, we need to re-render all Views
this._subscriptions.push(
this.eventPubSubService?.subscribe('onFilterChanged', this.redrawAllViewSlots.bind(this)),
this.eventPubSubService?.subscribe(['onGridMenuClearAllFilters', 'onGridMenuClearAllSorting'], () => window.setTimeout(() => this.redrawAllViewSlots())),
this.eventPubSubService?.subscribe('onGridMenuClearAllFilters', () => window.setTimeout(() => this.redrawAllViewSlots())),
this.eventPubSubService?.subscribe('onGridMenuClearAllSorting', () => window.setTimeout(() => this.redrawAllViewSlots())),
);
}
}
Expand Down

0 comments on commit f4d0550

Please sign in to comment.