Skip to content

Commit 5e4b14a

Browse files
authored
Revert "feat: add option to cancel Row Detail opening (#1125)" (#1127)
This reverts commit 82ba377.
1 parent 85a52d2 commit 5e4b14a

File tree

2 files changed

+6
-37
lines changed

2 files changed

+6
-37
lines changed

packages/row-detail-view-plugin/src/slickRowDetailView.spec.ts

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -306,40 +306,10 @@ describe('SlickRowDetailView plugin', () => {
306306
expect(stopPropagationSpy).not.toHaveBeenCalled();
307307
});
308308

309-
it('should trigger onClick and NOT expect Row Detail to be toggled when onBeforeRowDetailToggle returns false', () => {
310-
const mockProcess = jest.fn();
311-
const expandDetailViewSpy = jest.spyOn(plugin, 'expandDetailView');
312-
const onBeforeSlickEventData = new Slick.EventData();
313-
jest.spyOn(onBeforeSlickEventData, 'getReturnValue').mockReturnValue(false);
314-
const beforeRowDetailToggleSpy = jest.spyOn(plugin.onBeforeRowDetailToggle, 'notify').mockReturnValueOnce(onBeforeSlickEventData);
315-
const afterRowDetailToggleSpy = jest.spyOn(plugin.onAfterRowDetailToggle, 'notify');
316-
const itemMock = { id: 123, firstName: 'John', lastName: 'Doe', _collapsed: true };
317-
const detailView = `<span>loading...</span>`;
318-
jest.spyOn(gridStub.getEditorLock(), 'isActive').mockReturnValue(false);
319-
jest.spyOn(gridStub.getEditorLock(), 'commitCurrentEdit').mockReturnValue(true);
320-
jest.spyOn(gridStub, 'getDataItem').mockReturnValue(itemMock);
321-
jest.spyOn(gridStub, 'getColumns').mockReturnValue(mockColumns);
322-
jest.spyOn(gridStub, 'getOptions').mockReturnValue({ ...gridOptionsMock, rowDetailView: { process: mockProcess, columnIndexPosition: 0, useRowClick: true, maxRows: 2, panelRows: 2 } as any });
323-
324-
plugin.init(gridStub);
325-
plugin.onAsyncResponse.notify({ item: itemMock, itemDetail: itemMock, detailView, }, new Slick.EventData());
326-
327-
const clickEvent = new Event('click');
328-
Object.defineProperty(clickEvent, 'target', { writable: true, configurable: true, value: document.createElement('div') });
329-
Object.defineProperty(clickEvent, 'isPropagationStopped', { writable: true, configurable: true, value: jest.fn() });
330-
Object.defineProperty(clickEvent, 'isImmediatePropagationStopped', { writable: true, configurable: true, value: jest.fn() });
331-
gridStub.onClick.notify({ row: 0, cell: 1, grid: gridStub }, clickEvent);
332-
333-
expect(beforeRowDetailToggleSpy).toHaveBeenCalled();
334-
expect(afterRowDetailToggleSpy).not.toHaveBeenCalled();
335-
expect(expandDetailViewSpy).not.toHaveBeenCalled();
336-
});
337-
338-
it('should trigger onClick and expect Row Detail to be toggled', () => {
309+
it('should trigger onClick and ', () => {
339310
const mockProcess = jest.fn();
340311
const expandDetailViewSpy = jest.spyOn(plugin, 'expandDetailView');
341312
const beforeRowDetailToggleSpy = jest.spyOn(plugin.onBeforeRowDetailToggle, 'notify');
342-
const afterRowDetailToggleSpy = jest.spyOn(plugin.onAfterRowDetailToggle, 'notify');
343313
const itemMock = { id: 123, firstName: 'John', lastName: 'Doe', _collapsed: true };
344314
const detailView = `<span>loading...</span>`;
345315
jest.spyOn(gridStub.getEditorLock(), 'isActive').mockReturnValue(false);
@@ -358,7 +328,6 @@ describe('SlickRowDetailView plugin', () => {
358328
gridStub.onClick.notify({ row: 0, cell: 1, grid: gridStub }, clickEvent);
359329

360330
expect(beforeRowDetailToggleSpy).toHaveBeenCalled();
361-
expect(afterRowDetailToggleSpy).toHaveBeenCalled();
362331
expect(expandDetailViewSpy).toHaveBeenCalledWith({
363332
_collapsed: false, _detailContent: undefined, _detailViewLoaded: true,
364333
_height: 75, _sizePadding: 3, firstName: 'John', id: 123, lastName: 'Doe'
@@ -441,7 +410,7 @@ describe('SlickRowDetailView plugin', () => {
441410
_collapsed: true, _detailViewLoaded: true, _sizePadding: 0, _height: 150, _detailContent: '<span>loading...</span>',
442411
id: 123, firstName: 'John', lastName: 'Doe',
443412
}
444-
}, expect.anything(), expect.anything());
413+
});
445414
expect(afterRowDetailToggleSpy).toHaveBeenCalledWith({
446415
grid: gridStub,
447416
item: {

packages/row-detail-view-plugin/src/slickRowDetailView.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,10 +682,10 @@ export class SlickRowDetailView implements ExternalResource, UniversalRowDetailV
682682
}
683683

684684
// trigger an event before toggling
685-
// user could cancel the Row Detail opening when event is returning false
686-
if (this.onBeforeRowDetailToggle.notify({ grid: this._grid, item: dataContext }, e, this).getReturnValue() === false) {
687-
return;
688-
}
685+
this.onBeforeRowDetailToggle.notify({
686+
grid: this._grid,
687+
item: dataContext
688+
});
689689

690690
this.toggleRowSelection(args.row, dataContext);
691691

0 commit comments

Comments
 (0)