Skip to content

Commit c4c20dd

Browse files
authored
fix(Toolbar): Cancel export should hide the progress indicator. (#15917)
1 parent c02f007 commit c4c20dd

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid-toolbar.spec.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@ describe('IgxGrid - Grid Toolbar #grid - ', () => {
173173
expect($('#csvEntry').textContent).toMatch(instance.customCSVText);
174174
});
175175

176+
it('progress indicator should stop on canceling the export', () => {
177+
fixture.componentInstance.exportStartCancelled = true;
178+
fixture.detectChanges();
179+
$(TOOLBAR_EXPORTER_TAG).querySelector('button').click();
180+
fixture.detectChanges();
181+
$('#excelEntry').click();
182+
fixture.detectChanges();
183+
184+
expect(instance.exporterAction.isExporting).toBeFalse();
185+
expect(instance.exporterAction.toolbar.showProgress).toBeFalse();
186+
});
187+
176188
it('Setting overlaySettings for each toolbar columns action', () => {
177189
const defaultSettings = instance.pinningAction.overlaySettings;
178190
const defaultFiltSettings = instance.advancedFiltAction.overlaySettings;
@@ -297,7 +309,7 @@ export class DefaultToolbarComponent {
297309
<igx-grid-toolbar-advanced-filtering #advancedFiltAction>
298310
{{ advancedFilteringTitle }}
299311
</igx-grid-toolbar-advanced-filtering>
300-
<igx-grid-toolbar-exporter #exporterAction [exportCSV]="exportCSV" [exportExcel]="exportExcel" [filename]="exportFilename">
312+
<igx-grid-toolbar-exporter #exporterAction [exportCSV]="exportCSV" [exportExcel]="exportExcel" [filename]="exportFilename" (exportStarted)="exportStarted($event)">
301313
{{ exporterText }}
302314
<span id="excelEntry" excelText>{{ customExcelText }}</span>
303315
<span id="csvEntry" csvText>{{ customCSVText }}</span>
@@ -346,8 +358,15 @@ export class ToolbarActionsComponent {
346358
modal: true,
347359
closeOnEscape: false
348360
};
361+
public exportStartCancelled = false;
349362

350363
constructor() {
351364
this.data = [...DATA];
352365
}
366+
367+
public exportStarted(args) {
368+
if (this.exportStartCancelled) {
369+
args.cancel = true;
370+
}
371+
}
353372
}

projects/igniteui-angular/src/lib/grids/toolbar/grid-toolbar-exporter.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ export class IgxGridToolbarExporterComponent extends BaseToolbarDirective {
126126

127127
this.exportStarted.emit(args);
128128
this.grid.toolbarExporting.emit(args);
129-
this.isExporting = true;
130-
this.toolbar.showProgress = true;
131129

132130
if (args.cancel) {
133131
return;
134132
}
135133

134+
this.isExporting = true;
135+
this.toolbar.showProgress = true;
136+
136137
exporter.exportEnded.pipe(first()).subscribe(() => {
137138
this.exportEnded.emit();
138139
this.isExporting = false;

0 commit comments

Comments
 (0)