mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-24 07:16:52 -06:00
Ensure that the editor position should not get changed once it is opened. Fixes #7393
This commit is contained in:
parent
53bd2c2dc6
commit
5e0dfff42a
@ -24,3 +24,4 @@ Bug fixes
|
|||||||
| `Issue #7376 <https://redmine.postgresql.org/issues/7376>`_ - Fixed an issue where a popup for unsaved changes appears when clicking on the open file button for a blank query editor.
|
| `Issue #7376 <https://redmine.postgresql.org/issues/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 <https://redmine.postgresql.org/issues/7383>`_ - Fixed an issue where Preferences are not saved when the dialog is maximized.
|
| `Issue #7383 <https://redmine.postgresql.org/issues/7383>`_ - Fixed an issue where Preferences are not saved when the dialog is maximized.
|
||||||
| `Issue #7388 <https://redmine.postgresql.org/issues/7388>`_ - Fixed an issue where an error message fills the entire window if the query is long.
|
| `Issue #7388 <https://redmine.postgresql.org/issues/7388>`_ - Fixed an issue where an error message fills the entire window if the query is long.
|
||||||
|
| `Issue #7393 <https://redmine.postgresql.org/issues/7393>`_ - Ensure that the editor position should not get changed once it is opened.
|
||||||
|
@ -30,7 +30,7 @@ export default function ConnectServerContent({closeModal, data, onOK, setHeight}
|
|||||||
|
|
||||||
const onKeyDown = (e) => {
|
const onKeyDown = (e) => {
|
||||||
// If enter key is pressed then click on OK button
|
// If enter key is pressed then click on OK button
|
||||||
if (e.keyCode == 13) {
|
if (e.key === 'Enter') {
|
||||||
okBtnRef.current?.click();
|
okBtnRef.current?.click();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
import { makeStyles, Box, Portal } from '@material-ui/core';
|
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 { DefaultButton, PrimaryButton } from '../../../../../../static/js/components/Buttons';
|
||||||
import CheckRoundedIcon from '@material-ui/icons/CheckRounded';
|
import CheckRoundedIcon from '@material-ui/icons/CheckRounded';
|
||||||
import CloseIcon from '@material-ui/icons/Close';
|
import CloseIcon from '@material-ui/icons/Close';
|
||||||
@ -123,6 +123,10 @@ function setEditorPosition(cellEle, editorEle) {
|
|||||||
if(!editorEle || !cellEle) {
|
if(!editorEle || !cellEle) {
|
||||||
return;
|
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 gridEle = cellEle.closest('.rdg');
|
||||||
let cellRect = cellEle.getBoundingClientRect();
|
let cellRect = cellEle.getBoundingClientRect();
|
||||||
let position = {
|
let position = {
|
||||||
@ -158,6 +162,12 @@ function textColumnFinalVal(columnVal, column) {
|
|||||||
}
|
}
|
||||||
return columnVal;
|
return columnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function suppressEnterKey(e) {
|
||||||
|
if(e.keyCode == 13) {
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
}
|
||||||
export function TextEditor({row, column, onRowChange, onClose}) {
|
export function TextEditor({row, column, onRowChange, onClose}) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const value = row[column.key] ?? '';
|
const value = row[column.key] ?? '';
|
||||||
@ -186,7 +196,7 @@ export function TextEditor({row, column, onRowChange, onClose}) {
|
|||||||
<Portal container={document.body}>
|
<Portal container={document.body}>
|
||||||
<Box ref={(ele)=>{
|
<Box ref={(ele)=>{
|
||||||
setEditorPosition(getCellElement(column.idx), ele);
|
setEditorPosition(getCellElement(column.idx), ele);
|
||||||
}} className={classes.textEditor} data-label="pg-editor">
|
}} className={classes.textEditor} data-label="pg-editor" onKeyDown={suppressEnterKey} >
|
||||||
<textarea ref={autoFocusAndSelect} className={classes.textarea} value={localVal} onChange={onChange} />
|
<textarea ref={autoFocusAndSelect} className={classes.textarea} value={localVal} onChange={onChange} />
|
||||||
<Box display="flex" justifyContent="flex-end">
|
<Box display="flex" justifyContent="flex-end">
|
||||||
<DefaultButton startIcon={<CloseIcon />} onClick={()=>onClose(false)} size="small">
|
<DefaultButton startIcon={<CloseIcon />} onClick={()=>onClose(false)} size="small">
|
||||||
@ -240,7 +250,7 @@ export function NumberEditor({row, column, onRowChange, onClose}) {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
const onKeyDown = (e)=>{
|
const onKeyDown = (e)=>{
|
||||||
if(e.code == 'Tab') {
|
if(e.code === 'Tab' || e.code === 'Enter') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if(!onBlur()) {
|
if(!onBlur()) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@ -267,6 +277,7 @@ NumberEditor.propTypes = EditorPropTypes;
|
|||||||
export function CheckboxEditor({row, column, onRowChange, onClose}) {
|
export function CheckboxEditor({row, column, onRowChange, onClose}) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const value = row[column.key] ?? null;
|
const value = row[column.key] ?? null;
|
||||||
|
const containerRef = useRef();
|
||||||
const changeValue = ()=>{
|
const changeValue = ()=>{
|
||||||
if(!column.can_edit) {
|
if(!column.can_edit) {
|
||||||
return;
|
return;
|
||||||
@ -286,8 +297,21 @@ export function CheckboxEditor({row, column, onRowChange, onClose}) {
|
|||||||
} else if(value == null){
|
} else if(value == null){
|
||||||
className = 'intermediate';
|
className = 'intermediate';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onSpaceHit = (e)=>{
|
||||||
|
if(e.code === 'Space') {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
changeValue();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useLayoutEffect(()=>{
|
||||||
|
containerRef.current.focus();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div onClick={changeValue} tabIndex="0" onBlur={onBlur} data-label="pg-checkbox-editor">
|
<div ref={containerRef} onClick={changeValue} onKeyDown={onSpaceHit} tabIndex="0" onBlur={onBlur} data-label="pg-checkbox-editor">
|
||||||
<span className={clsx(classes.check, className)}></span>
|
<span className={clsx(classes.check, className)}></span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -334,7 +358,7 @@ export function JsonTextEditor({row, column, onRowChange, onClose}) {
|
|||||||
<Portal container={document.body}>
|
<Portal container={document.body}>
|
||||||
<Box ref={(ele)=>{
|
<Box ref={(ele)=>{
|
||||||
setEditorPosition(getCellElement(column.idx), ele);
|
setEditorPosition(getCellElement(column.idx), ele);
|
||||||
}} className={classes.jsonEditor} data-label="pg-editor">
|
}} className={classes.jsonEditor} data-label="pg-editor" onKeyDown={suppressEnterKey} >
|
||||||
<JsonEditor
|
<JsonEditor
|
||||||
value={localVal}
|
value={localVal}
|
||||||
options={{
|
options={{
|
||||||
|
@ -115,9 +115,14 @@ function CustomRow(props) {
|
|||||||
} else if(props.selectedCellIdx == 0) {
|
} else if(props.selectedCellIdx == 0) {
|
||||||
dataGridExtras.onSelectedCellChange?.(null);
|
dataGridExtras.onSelectedCellChange?.(null);
|
||||||
}
|
}
|
||||||
|
const openEditorOnEnter = (e)=>{
|
||||||
|
if(e.code === 'Enter' && !props.isRowSelected && props.selectedCellIdx > 0) {
|
||||||
|
props.selectCell(props.row, props.viewportColumns?.[props.selectedCellIdx], true);
|
||||||
|
}
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<RowInfoContext.Provider value={rowInfoValue}>
|
<RowInfoContext.Provider value={rowInfoValue}>
|
||||||
<Row ref={rowRef} {...props} />
|
<Row ref={rowRef} onKeyDown={openEditorOnEnter} {...props} />
|
||||||
</RowInfoContext.Provider>
|
</RowInfoContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -128,6 +133,7 @@ CustomRow.propTypes = {
|
|||||||
selectedCellIdx: PropTypes.number,
|
selectedCellIdx: PropTypes.number,
|
||||||
row: PropTypes.object,
|
row: PropTypes.object,
|
||||||
viewportColumns: PropTypes.array,
|
viewportColumns: PropTypes.array,
|
||||||
|
selectCell: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getCopyShortcutHandler(handleCopy) {
|
function getCopyShortcutHandler(handleCopy) {
|
||||||
@ -391,9 +397,7 @@ export default function QueryToolDataGrid({columns, rows, totalRowCount, dataCha
|
|||||||
}, [dataChangeStore, selectedColumns]);
|
}, [dataChangeStore, selectedColumns]);
|
||||||
|
|
||||||
function handleCopy() {
|
function handleCopy() {
|
||||||
if (window.isSecureContext) {
|
eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_COPY_DATA);
|
||||||
eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_COPY_DATA);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user