From 221c05d8d6345d090074c92e423071888e4a2686 Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Mon, 8 Nov 2021 17:46:48 -0500 Subject: [PATCH] fix(context): strin hidden special chars on context menu Copy command --- .../__tests__/contextMenuExtension.spec.ts | 4 ++-- .../src/extensions/contextMenuExtension.ts | 4 ++-- .../src/formatters/formatterUtilities.ts | 5 +++-- .../slickgrid-vanilla-bundle.zip | Bin 567293 -> 567369 bytes 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/common/src/extensions/__tests__/contextMenuExtension.spec.ts b/packages/common/src/extensions/__tests__/contextMenuExtension.spec.ts index 55041ba50..1c8865430 100644 --- a/packages/common/src/extensions/__tests__/contextMenuExtension.spec.ts +++ b/packages/common/src/extensions/__tests__/contextMenuExtension.spec.ts @@ -643,7 +643,7 @@ describe('contextMenuExtension', () => { it('should call "copyToClipboard" and get the value even when there is a "queryFieldNameGetterFn" callback defined with dot notation the command triggered is "copy"', () => { const copyGridOptionsMock = { ...gridOptionsMock, enableExcelExport: false, enableTextExport: false, contextMenu: { hideCopyCellValueCommand: false } } as GridOption; const columnMock = { id: 'firstName', name: 'First Name', field: 'firstName', queryFieldNameGetterFn: () => 'lastName' } as Column; - const dataContextMock = { id: 123, firstName: 'John', lastName: 'Doe', age: 50 }; + const dataContextMock = { id: 123, firstName: '\u034f\u034fJohny', lastName: '\u034f\u034fDoe', age: 50 }; jest.spyOn(SharedService.prototype, 'gridOptions', 'get').mockReturnValue(copyGridOptionsMock); const execSpy = jest.spyOn(window.document, 'execCommand'); extension.register(); @@ -667,7 +667,7 @@ describe('contextMenuExtension', () => { it('should call "copyToClipboard" and get the value even when there is a "queryFieldNameGetterFn" callback defined with dot notation the command triggered is "copy"', () => { const copyGridOptionsMock = { ...gridOptionsMock, enableExcelExport: false, enableTextExport: false, contextMenu: { hideCopyCellValueCommand: false } } as GridOption; const columnMock = { id: 'firstName', name: 'First Name', field: 'firstName', queryFieldNameGetterFn: () => 'user.lastName' } as Column; - const dataContextMock = { id: 123, user: { firstName: 'John', lastName: 'Doe', age: 50 } }; + const dataContextMock = { id: 123, user: { firstName: 'John', lastName: '·\u034f ⮞ Doe', age: 50 } }; jest.spyOn(SharedService.prototype, 'gridOptions', 'get').mockReturnValue(copyGridOptionsMock); const execSpy = jest.spyOn(window.document, 'execCommand'); extension.register(); diff --git a/packages/common/src/extensions/contextMenuExtension.ts b/packages/common/src/extensions/contextMenuExtension.ts index 704a5d382..56978fd7c 100644 --- a/packages/common/src/extensions/contextMenuExtension.ts +++ b/packages/common/src/extensions/contextMenuExtension.ts @@ -427,7 +427,7 @@ export class ContextMenuExtension implements Extension { } // remove any unwanted Tree Data/Grouping symbols from the beginning of the string before copying (e.g.: "⮟ Task 21" or "· Task 2") - const finalTextToCopy = textToCopy.replace(/^([·|⮞|⮟]\s*)|([·|⮞|⮟])\s*/g, ''); + const finalTextToCopy = textToCopy.replace(/^([·|⮞|⮟]\s*)|([·|⮞|⮟])\s*/gi, '').replace(/\u034f/gi, '').trim(); // create fake