From db9b8a7156c8e4eef8fd68df0123333683ad6a8c Mon Sep 17 00:00:00 2001 From: Naumov Alexey Date: Mon, 5 Apr 2021 16:55:06 +0300 Subject: [PATCH] fix(plugin-data-spreadsheet-new): CB-743, CB-851, CB-902, CB-903 run mouse up callback only if grid in focus --- .../CreateConnection/CreateConnection.tsx | 4 ---- .../src/ConnectionForm/SSH/SSH.tsx | 1 + .../src/DataGrid/CellRenderer/CellRenderer.tsx | 6 +++++- .../src/DataGrid/DataGridContext.ts | 1 + .../src/DataGrid/DataGridTable.tsx | 3 +++ .../src/GISViewerBootstrap.ts | 18 +++++++----------- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/webapp/packages/core-connections/src/Administration/Connections/CreateConnection/CreateConnection.tsx b/webapp/packages/core-connections/src/Administration/Connections/CreateConnection/CreateConnection.tsx index 9d58d7d300..eb7244077a 100644 --- a/webapp/packages/core-connections/src/Administration/Connections/CreateConnection/CreateConnection.tsx +++ b/webapp/packages/core-connections/src/Administration/Connections/CreateConnection/CreateConnection.tsx @@ -79,10 +79,6 @@ const styles = composes( flex: auto 0 0; } - IconButton { - color: rgba(0, 0, 0, 0.45); - } - StaticImage { width: 32px; max-height: 32px; diff --git a/webapp/packages/core-connections/src/ConnectionForm/SSH/SSH.tsx b/webapp/packages/core-connections/src/ConnectionForm/SSH/SSH.tsx index c739855979..938ea96501 100644 --- a/webapp/packages/core-connections/src/ConnectionForm/SSH/SSH.tsx +++ b/webapp/packages/core-connections/src/ConnectionForm/SSH/SSH.tsx @@ -167,6 +167,7 @@ export const SSH: TabContainerPanelComponent = observer type='button' mod={['outlined']} disabled={disabled || !enabled || !passwordFilled} + loading={loading} onClick={testConnection} > {translate('connections_network_handler_test')} diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/CellRenderer/CellRenderer.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/CellRenderer/CellRenderer.tsx index 5778bceec0..a41ceb31e3 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/CellRenderer/CellRenderer.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/CellRenderer/CellRenderer.tsx @@ -58,6 +58,10 @@ export const CellRenderer: React.FC> = observer(function }, [column, rowIdx, selectionContext]); const handleMouseUp = useCallback((event: React.MouseEvent) => { + if (!dataGridContext?.isGridInFocus()) { + return; + } + selectionContext?.select( { colIdx: column.idx, @@ -67,7 +71,7 @@ export const CellRenderer: React.FC> = observer(function event.shiftKey, false ); - }, [column, rowIdx, selectionContext]); + }, [column, rowIdx, selectionContext, dataGridContext]); const handleDoubleClick = useCallback(() => { if (!column.editable) { diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContext.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContext.ts index 53017b49a8..3fdcf359ea 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContext.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContext.ts @@ -21,6 +21,7 @@ export interface IDataGridContext { model: IDatabaseDataModel; resultIndex: number; columnResize: IExecutor; + isGridInFocus: () => boolean; getEditorPortal: () => HTMLDivElement | null; getDataGridApi: () => DataGridHandle | null; } diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx index 95488c2ed6..f7bbbe9193 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx @@ -45,6 +45,7 @@ function isAtBottom(event: React.UIEvent): boolean { } export const DataGridTable: React.FC = observer(function DataGridTable({ model, resultIndex, className }) { + const gridContainerRef = useRef(null); const dataGridRef = useRef(null); const editorRef = useRef(null); const styles = useStyles(reactGridStyles, baseStyles); @@ -149,6 +150,7 @@ export const DataGridTable: React.FC = observer(function DataGridTable({ model, columnResize, resultIndex, + isGridInFocus: () => gridContainerRef.current === document.activeElement, getEditorPortal: () => editorRef.current, getDataGridApi: () => dataGridRef.current, }), [model, resultIndex, editorRef, dataGridRef]); @@ -160,6 +162,7 @@ export const DataGridTable: React.FC = observer(function DataGridTable({ 0) { - const firstSelectedCell = selectedCells[0]; - - return !gis.isGISFormat(firstSelectedCell); - } - - return true; }, }); }