From f4d0550c555faeb16772a1b1f3717ba538ca3feb Mon Sep 17 00:00:00 2001 From: "Ghislain B." Date: Fri, 18 Oct 2024 23:11:59 -0400 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20redraw=20all=20open=20row=20de?= =?UTF-8?q?tails=20whenever=20the=20grid=20is=20re-rendered=20(#1=E2=80=A6?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4ecb4393a8033ddc4c0f68a2c6242dc6cb0da21f. --- .../src/extensions/__tests__/slickRowDetailView.spec.ts | 8 ++++---- .../src/extensions/slickRowDetailView.ts | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/aurelia-slickgrid/src/extensions/__tests__/slickRowDetailView.spec.ts b/packages/aurelia-slickgrid/src/extensions/__tests__/slickRowDetailView.spec.ts index 9d7b0ee66..535e28ce4 100644 --- a/packages/aurelia-slickgrid/src/extensions/__tests__/slickRowDetailView.spec.ts +++ b/packages/aurelia-slickgrid/src/extensions/__tests__/slickRowDetailView.spec.ts @@ -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; @@ -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(); }); @@ -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 @@ -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 }), diff --git a/packages/aurelia-slickgrid/src/extensions/slickRowDetailView.ts b/packages/aurelia-slickgrid/src/extensions/slickRowDetailView.ts index 3f55ee4a5..9f12e7156 100644 --- a/packages/aurelia-slickgrid/src/extensions/slickRowDetailView.ts +++ b/packages/aurelia-slickgrid/src/extensions/slickRowDetailView.ts @@ -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) { @@ -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())), ); } }