public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][patch] Autofocus CodeMirror input in SchemaView
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin][patch] Autofocus CodeMirror input in SchemaView
@ 2022-04-28 07:14 Aditya Toshniwal <[email protected]>
  2022-04-28 08:39 ` Re: [pgAdmin][patch] Autofocus CodeMirror input in SchemaView Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Aditya Toshniwal @ 2022-04-28 07:14 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Hackers,

Attached patch allows to autofocus CodeMirror SQL input if it is the first
element in the form.
Please review.

-- 
Thanks,
Aditya Toshniwal
pgAdmin Hacker | Software Architect | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"


Attachments:

  [application/octet-stream] autfocus.cm.patch (2.0K, 3-autfocus.cm.patch)
  download | inline diff:
diff --git a/web/pgadmin/static/js/SchemaView/MappedControl.jsx b/web/pgadmin/static/js/SchemaView/MappedControl.jsx
index 4196d3fd3..4a0f26746 100644
--- a/web/pgadmin/static/js/SchemaView/MappedControl.jsx
+++ b/web/pgadmin/static/js/SchemaView/MappedControl.jsx
@@ -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':
diff --git a/web/pgadmin/static/js/components/FormComponents.jsx b/web/pgadmin/static/js/components/FormComponents.jsx
index eade7b045..28812238a 100644
--- a/web/pgadmin/static/js/components/FormComponents.jsx
+++ b/web/pgadmin/static/js/components/FormComponents.jsx
@@ -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 }) {


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin][patch] Autofocus CodeMirror input in SchemaView
  2022-04-28 07:14 [pgAdmin][patch] Autofocus CodeMirror input in SchemaView Aditya Toshniwal <[email protected]>
@ 2022-04-28 08:39 ` Akshay Joshi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2022-04-28 08:39 UTC (permalink / raw)
  To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers

Thanks, the patch applied.

On Thu, Apr 28, 2022 at 12:45 PM Aditya Toshniwal <
[email protected]> wrote:

> Hi Hackers,
>
> Attached patch allows to autofocus CodeMirror SQL input if it is the first
> element in the form.
> Please review.
>
> --
> Thanks,
> Aditya Toshniwal
> pgAdmin Hacker | Software Architect | *edbpostgres.com*
> <http://edbpostgres.com;
> "Don't Complain about Heat, Plant a TREE"
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2022-04-28 08:39 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 07:14 [pgAdmin][patch] Autofocus CodeMirror input in SchemaView Aditya Toshniwal <[email protected]>
2022-04-28 08:39 ` Akshay Joshi <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox