Skip to content

Commit

Permalink
fix(collectionAsync): hidden column does not load edit field selection
Browse files Browse the repository at this point in the history
- replicate issue found and fixed in Slickgrid-Universal [PR 742](ghiscoding/slickgrid-universal#742)
  • Loading branch information
ghiscoding committed Aug 15, 2022
1 parent 1d7339b commit 0b2db3d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,11 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
it('should be able to load async editors with an Observable', (done) => {
const mockCollection = ['male', 'female'];
const mockColDefs = [{ id: 'gender', field: 'gender', editor: { model: Editors.text, collectionAsync: of(mockCollection) } }] as Column[];
const getColSpy = jest.spyOn(mockGrid, 'getColumns').mockReturnValue(mockColDefs);

component.ngAfterViewInit();
component.columnDefinitions = mockColDefs;

setTimeout(() => {
expect(getColSpy).toHaveBeenCalled();
expect(component.columnDefinitions[0].editor).toBeTruthy();
expect(component.columnDefinitions[0].editor!.collection).toEqual(mockCollection);
expect(component.columnDefinitions[0].internalColumnEditor!.collection).toEqual(mockCollection);
Expand All @@ -711,7 +709,6 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
renderDomElement: jest.fn(),
} as unknown as Editor;
const mockColDefs = [{ id: 'gender', field: 'gender', editor: { model: Editors.text, collectionAsync: promise } }] as Column[];
const getColSpy = jest.spyOn(mockGrid, 'getColumns').mockReturnValue(mockColDefs);
jest.spyOn(mockGrid, 'getCellEditor').mockReturnValue(mockEditor);
const disableSpy = jest.spyOn(mockEditor, 'disable');
const destroySpy = jest.spyOn(mockEditor, 'destroy');
Expand All @@ -721,7 +718,6 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
component.columnDefinitions = mockColDefs;

setTimeout(() => {
expect(getColSpy).toHaveBeenCalled();
expect(component.columnDefinitions[0].editor).toBeTruthy();
expect(component.columnDefinitions[0].editor!.collection).toEqual(mockCollection);
expect(component.columnDefinitions[0].internalColumnEditor!.collection).toEqual(mockCollection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1375,9 +1375,8 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy {
(column.editor as ColumnEditor).disabled = false;

// find the new column reference pointer & re-assign the new editor to the internalColumnEditor
const columns = this.slickGrid.getColumns();
if (Array.isArray(columns)) {
const columnRef = columns.find((col: Column) => col.id === column.id);
if (Array.isArray(this.columnDefinitions)) {
const columnRef = this.columnDefinitions.find((col: Column) => col.id === column.id);
if (columnRef) {
columnRef.internalColumnEditor = column.editor as ColumnEditor;
}
Expand Down

0 comments on commit 0b2db3d

Please sign in to comment.