From 058631ec57a832bee3c39ae791b98cf45c24a245 Mon Sep 17 00:00:00 2001 From: Aleksei Potsetsuev Date: Thu, 11 Apr 2024 23:52:36 +0800 Subject: [PATCH] CB-4699 fix: prevent cell copy in editing mode --- .../src/DataGrid/useGridSelectedCellsCopy.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/useGridSelectedCellsCopy.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/useGridSelectedCellsCopy.ts index c5b4889002..a9f0949395 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/useGridSelectedCellsCopy.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/useGridSelectedCellsCopy.ts @@ -74,6 +74,14 @@ export function useGridSelectedCellsCopy( const onKeydownHandler = useCallback((event: React.KeyboardEvent) => { if ((event.ctrlKey || event.metaKey) && event.nativeEvent.code === EVENT_KEY_CODE.C) { + const activeElement = document.activeElement as HTMLElement | null; + if ( + activeElement?.getAttribute('role') !== 'gridcell' && + activeElement?.getAttribute('role') !== 'columnheader' && + event.target !== event.currentTarget + ) { + return; + } EventContext.set(event, EventStopPropagationFlag); if (dataViewerService.canCopyData) {