Skip to content

Commit 400ba57

Browse files
authored
Merge pull request #10381 from IgniteUI/kdragieva/single-cell-value-master
feat(IgxGridBaseDirective): Remove newline character when single cell value is copied
2 parents 5eb3e44 + 81a5269 commit 400ba57

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5520,7 +5520,6 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
55205520
data = selectedData;
55215521
result = this.prepareCopyData(event, data);
55225522
}
5523-
55245523
if (this.platform.isIE) {
55255524
(window as any).clipboardData.setData('Text', result);
55265525
return;
@@ -5547,6 +5546,10 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
55475546
result = result.substring(result.indexOf('\n') + 1);
55485547
}
55495548

5549+
if (Object.values(data[0]).length === 1) {
5550+
result = result.slice(0, -2);
5551+
}
5552+
55505553
event.preventDefault();
55515554

55525555
/* Necessary for the hiearachical case but will probably have to

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ describe('IgxGrid - Clipboard #grid', () => {
6161

6262
let eventData = dispatchCopyEventOnGridBody(fix);
6363
expect(copySpy).toHaveBeenCalledTimes(1);
64-
expect(eventData).toEqual('ID;ProductNameHeader\r\n1;\r\n;** NetAdvantage **\r\n');
64+
expect(eventData).toEqual('ID;ProductNameHeader\r\n1;\r\n;** NetAdvantage **');
6565

6666
grid.clipboardOptions.separator = ',';
6767
fix.detectChanges();
6868

6969
eventData = dispatchCopyEventOnGridBody(fix);
7070
expect(copySpy).toHaveBeenCalledTimes(2);
71-
expect(eventData).toEqual('ID,ProductNameHeader\r\n1,\r\n,** NetAdvantage **\r\n');
71+
expect(eventData).toEqual('ID,ProductNameHeader\r\n1,\r\n,** NetAdvantage **');
7272
});
7373

7474
it('Copy data without headers', () => {
@@ -126,13 +126,13 @@ describe('IgxGrid - Clipboard #grid', () => {
126126

127127
let eventData = dispatchCopyEventOnGridBody(fix);
128128
expect(copySpy).toHaveBeenCalledTimes(1);
129-
expect(eventData).toEqual('ProductNameHeader\r\nNetAdvantage\r\nIgnite UI for Angular\r\n\r\n');
129+
expect(eventData).toEqual('ProductNameHeader\r\nNetAdvantage\r\nIgnite UI for Angular\r\n');
130130
grid.clipboardOptions.copyFormatters = true;
131131
fix.detectChanges();
132132

133133
eventData = dispatchCopyEventOnGridBody(fix);
134134
expect(copySpy).toHaveBeenCalledTimes(2);
135-
expect(eventData).toEqual('ProductNameHeader\r\n** NetAdvantage **\r\n** Ignite UI for Angular **\r\n** null **\r\n');
135+
expect(eventData).toEqual('ProductNameHeader\r\n** NetAdvantage **\r\n** Ignite UI for Angular **\r\n** null **');
136136
});
137137

138138
it('Cancel gridCopy event ', () => {

0 commit comments

Comments
 (0)