mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Autofocus CodeMirror SQL input to the first element of a form.
This commit is contained in:
parent
7c61017f57
commit
bd799ea51a
@ -75,7 +75,7 @@ function MappedFormControlBase({ type, value, id, onChange, className, visible,
|
||||
case 'file':
|
||||
return <FormInputFileSelect name={name} value={value} onChange={onTextChange} className={className} inputRef={inputRef} {...props} />;
|
||||
case 'sql':
|
||||
return <FormInputSQL name={name} value={value} onChange={onSqlChange} className={className} noLabel={noLabel} {...props} />;
|
||||
return <FormInputSQL name={name} value={value} onChange={onSqlChange} className={className} noLabel={noLabel} inputRef={inputRef} {...props} />;
|
||||
case 'note':
|
||||
return <FormNote className={className} {...props} />;
|
||||
case 'datetimepicker':
|
||||
|
@ -155,13 +155,16 @@ FormInput.propTypes = {
|
||||
testcid: PropTypes.any,
|
||||
};
|
||||
|
||||
export function InputSQL({ value, options, onChange, className, controlProps, ...props }) {
|
||||
export function InputSQL({ value, options, onChange, className, controlProps, inputRef, ...props }) {
|
||||
const classes = useStyles();
|
||||
const editor = useRef();
|
||||
|
||||
return (
|
||||
<CodeMirror
|
||||
currEditor={(obj) => editor.current = obj}
|
||||
currEditor={(obj) => {
|
||||
editor.current = obj;
|
||||
inputRef?.(obj);
|
||||
}}
|
||||
value={value || ''}
|
||||
options={{
|
||||
lineNumbers: true,
|
||||
@ -186,6 +189,7 @@ InputSQL.propTypes = {
|
||||
readonly: PropTypes.bool,
|
||||
className: CustomPropTypes.className,
|
||||
controlProps: PropTypes.object,
|
||||
inputRef: CustomPropTypes.ref,
|
||||
};
|
||||
|
||||
export function FormInputSQL({ hasError, required, label, className, helpMessage, testcid, value, controlProps, noLabel, ...props }) {
|
||||
|
Loading…
Reference in New Issue
Block a user