Skip to content

Commit

Permalink
Ensure focus is not changed to ssh tunnel input box when user explici…
Browse files Browse the repository at this point in the history
…tly focus in server password edit box
  • Loading branch information
nikhil-mohite committed Nov 28, 2023
1 parent 338bb64 commit 73640ba
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions web/pgadmin/static/js/Dialogs/ConnectServerContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//
//////////////////////////////////////////////////////////////

import React, { useState, useRef, useEffect } from 'react';
import React, { useState, useRef, useEffect, useLayoutEffect } from 'react';
import gettext from 'sources/gettext';
import { Box } from '@material-ui/core';
import { DefaultButton, PrimaryButton } from '../components/Buttons';
Expand All @@ -21,6 +21,7 @@ export default function ConnectServerContent({closeModal, data, onOK, setHeight}
const classes = useModalStyles();
const containerRef = useRef();
const firstEleRef = useRef();
const [firstElState, setFirstElState] = useState();
const okBtnRef = useRef();
const [formData, setFormData] = useState({
tunnel_password: '',
Expand All @@ -44,10 +45,11 @@ export default function ConnectServerContent({closeModal, data, onOK, setHeight}
}
};

useEffect(()=>{
setTimeout(()=>{
firstEleRef.current && firstEleRef.current.focus();
}, 350);

useLayoutEffect(()=>{
if(!firstElState){
firstEleRef.current && firstEleRef.current.focus(), setFirstElState(firstEleRef.current);
}
}, [firstEleRef.current]);

useEffect(()=>{
Expand Down

0 comments on commit 73640ba

Please sign in to comment.