From 5e0dfff42a4bdde75575fa26c03c054b8fa1d8a4 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Wed, 18 May 2022 13:52:09 +0530 Subject: [PATCH] Ensure that the editor position should not get changed once it is opened. Fixes #7393 --- docs/en_US/release_notes_6_10.rst | 1 + .../static/js/ConnectServerContent.jsx | 2 +- .../components/QueryToolDataGrid/Editors.jsx | 34 ++++++++++++++++--- .../js/components/QueryToolDataGrid/index.jsx | 12 ++++--- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/docs/en_US/release_notes_6_10.rst b/docs/en_US/release_notes_6_10.rst index 7767a2175..4f475159f 100644 --- a/docs/en_US/release_notes_6_10.rst +++ b/docs/en_US/release_notes_6_10.rst @@ -24,3 +24,4 @@ Bug fixes | `Issue #7376 `_ - Fixed an issue where a popup for unsaved changes appears when clicking on the open file button for a blank query editor. | `Issue #7383 `_ - Fixed an issue where Preferences are not saved when the dialog is maximized. | `Issue #7388 `_ - Fixed an issue where an error message fills the entire window if the query is long. + | `Issue #7393 `_ - Ensure that the editor position should not get changed once it is opened. diff --git a/web/pgadmin/browser/static/js/ConnectServerContent.jsx b/web/pgadmin/browser/static/js/ConnectServerContent.jsx index 05dbf8a8f..7ddb4d13d 100644 --- a/web/pgadmin/browser/static/js/ConnectServerContent.jsx +++ b/web/pgadmin/browser/static/js/ConnectServerContent.jsx @@ -30,7 +30,7 @@ export default function ConnectServerContent({closeModal, data, onOK, setHeight} const onKeyDown = (e) => { // If enter key is pressed then click on OK button - if (e.keyCode == 13) { + if (e.key === 'Enter') { okBtnRef.current?.click(); } }; diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx index 6839cf65b..35a82d5ac 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx @@ -7,7 +7,7 @@ // ////////////////////////////////////////////////////////////// import { makeStyles, Box, Portal } from '@material-ui/core'; -import React, {useContext} from 'react'; +import React, {useContext, useLayoutEffect, useRef} from 'react'; import { DefaultButton, PrimaryButton } from '../../../../../../static/js/components/Buttons'; import CheckRoundedIcon from '@material-ui/icons/CheckRounded'; import CloseIcon from '@material-ui/icons/Close'; @@ -123,6 +123,10 @@ function setEditorPosition(cellEle, editorEle) { if(!editorEle || !cellEle) { return; } + /* Once the position is set, then don't change it */ + if(editorEle.style.left || editorEle.style.top) { + return; + } let gridEle = cellEle.closest('.rdg'); let cellRect = cellEle.getBoundingClientRect(); let position = { @@ -158,6 +162,12 @@ function textColumnFinalVal(columnVal, column) { } return columnVal; } + +function suppressEnterKey(e) { + if(e.keyCode == 13) { + e.stopPropagation(); + } +} export function TextEditor({row, column, onRowChange, onClose}) { const classes = useStyles(); const value = row[column.key] ?? ''; @@ -186,7 +196,7 @@ export function TextEditor({row, column, onRowChange, onClose}) { { setEditorPosition(getCellElement(column.idx), ele); - }} className={classes.textEditor} data-label="pg-editor"> + }} className={classes.textEditor} data-label="pg-editor" onKeyDown={suppressEnterKey} >