Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit da62a48

Browse files
authored
fix(plugins): do not recreate header button plugin after re-render (#706)
* fix(filters): use defaultFilterOperator in range when none provided - when using 2 dots notation (`2..5`), we should use `defaultFilterRangeOperator` when none is provided and/or isn't a range operator * fix(plugins): do not recreate header button plugin after re-render - there is no need to recreate the header button because if we do that then we lose previous ref and onCommand stops working
1 parent 959fc38 commit da62a48

File tree

2 files changed

+4
-39
lines changed

2 files changed

+4
-39
lines changed

src/app/modules/angular-slickgrid/services/__tests__/extension.service.spec.ts

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ describe('ExtensionService', () => {
180180
expect(gridSpy).toHaveBeenCalled();
181181
expect(getAddonSpy).toHaveBeenCalled();
182182
expect(extSpy).toHaveBeenCalled();
183-
expect(output.instance).toEqual(instance);
183+
expect(output!.instance).toEqual(instance);
184184
expect(output).toEqual({ name: ExtensionName.gridMenu, addon: instanceMock, instance: instanceMock, class: extensionGridMenuStub } as ExtensionModel);
185185
});
186186
});
@@ -259,7 +259,7 @@ describe('ExtensionService', () => {
259259
expect(gridSpy).toHaveBeenCalled();
260260
expect(getAddonSpy).toHaveBeenCalled();
261261
expect(extSpy).toHaveBeenCalled();
262-
expect(output.instance).toEqual(instance);
262+
expect(output!.instance).toEqual(instance);
263263
expect(output).toEqual({ name: ExtensionName.gridMenu, addon: instanceMock, instance: instanceMock, class: extensionGridMenuStub } as ExtensionModel);
264264
});
265265

@@ -448,7 +448,7 @@ describe('ExtensionService', () => {
448448
});
449449

450450
describe('createExtensionsBeforeGridCreation method', () => {
451-
let instanceMock;
451+
let instanceMock: any;
452452

453453
beforeEach(() => {
454454
instanceMock = { onColumnsChanged: () => { } };
@@ -703,36 +703,6 @@ describe('ExtensionService', () => {
703703
expect(setColumnsSpy).toHaveBeenCalledWith(columnsMock);
704704
});
705705

706-
it('should re-register the Header Button when enable and method is called with new column definition collection provided as argument', () => {
707-
const instanceMock = { onColumnsChanged: jest.fn() };
708-
const extensionMock = { name: ExtensionName.headerButton, addon: null, instance: null, class: null } as ExtensionModel;
709-
const expectedExtension = { name: ExtensionName.headerButton, instance: instanceMock as unknown, class: null } as ExtensionModel;
710-
const gridOptionsMock = { enableHeaderButton: true } as GridOption;
711-
const columnsMock = [
712-
{ id: 'field1', field: 'field1', nameKey: 'HELLO' },
713-
{ id: 'field2', field: 'field2', nameKey: 'WORLD' }
714-
] as Column[];
715-
716-
jest.spyOn(SharedService.prototype, 'gridOptions', 'get').mockReturnValue(gridOptionsMock);
717-
jest.spyOn(SharedService.prototype, 'grid', 'get').mockReturnValue(gridStub);
718-
const spyGetExt = jest.spyOn(service, 'getExtensionByName').mockReturnValue(extensionMock);
719-
const spyGmDispose = jest.spyOn(extensionHeaderButtonStub, 'dispose');
720-
const spyGmRegister = jest.spyOn(extensionHeaderButtonStub, 'register').mockReturnValue(instanceMock);
721-
const spyAllCols = jest.spyOn(SharedService.prototype, 'allColumns', 'set');
722-
const setColumnsSpy = jest.spyOn(gridStub, 'setColumns');
723-
724-
service.renderColumnHeaders(columnsMock);
725-
726-
expect(expectedExtension).toEqual(expectedExtension);
727-
expect(spyGetExt).toHaveBeenCalled();
728-
expect(expectedExtension).toEqual(expectedExtension);
729-
expect(spyGetExt).toHaveBeenCalled();
730-
expect(spyGmDispose).toHaveBeenCalled();
731-
expect(spyGmRegister).toHaveBeenCalled();
732-
expect(spyAllCols).toHaveBeenCalledWith(columnsMock);
733-
expect(setColumnsSpy).toHaveBeenCalledWith(columnsMock);
734-
});
735-
736706
it('should re-register the Header Menu when enable and method is called with new column definition collection provided as argument', () => {
737707
const instanceMock = { onColumnsChanged: jest.fn() };
738708
const extensionMock = { name: ExtensionName.headerMenu, addon: null, instance: null, class: null } as ExtensionModel;
@@ -767,7 +737,7 @@ describe('ExtensionService', () => {
767737

768738
describe('without ngx-translate', () => {
769739
beforeEach(() => {
770-
translate = null;
740+
(translate as any) = null;
771741
service = new ExtensionService(
772742
// extensions
773743
extensionStub as unknown as AutoTooltipExtension,

src/app/modules/angular-slickgrid/services/extension.service.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,6 @@ export class ExtensionService {
429429
this.recreateExternalAddon(this.gridMenuExtension, ExtensionName.gridMenu);
430430
}
431431

432-
// recreate the Header Button when enabled
433-
if (this.sharedService.gridOptions.enableHeaderButton) {
434-
this.recreateExternalAddon(this.headerButtonExtension, ExtensionName.headerButton);
435-
}
436-
437432
// recreate the Header Menu when enabled
438433
if (this.sharedService.gridOptions.enableHeaderMenu) {
439434
this.recreateExternalAddon(this.headerMenuExtension, ExtensionName.headerMenu);

0 commit comments

Comments
 (0)