mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that cursor should be focused on the first options of the Utility dialogs. Fixes #7110
This commit is contained in:
committed by
Akshay Joshi
parent
4d727015fd
commit
b4b658c59d
@@ -150,7 +150,7 @@ export default function FormView({
|
||||
let tabsClassname = {};
|
||||
const [tabValue, setTabValue] = useState(0);
|
||||
const classes = useStyles();
|
||||
const firstElement = useRef();
|
||||
const firstEleSet = useRef();
|
||||
const formRef = useRef();
|
||||
const onScreenTracker = useRef(false);
|
||||
const depListener = useContext(DepListenerContext);
|
||||
@@ -201,6 +201,8 @@ export default function FormView({
|
||||
}, [stateUtils.formResetKey]);
|
||||
|
||||
let fullTabs = [];
|
||||
// To check if the first element ref is set.
|
||||
firstEleSet.current = false;
|
||||
|
||||
/* Prepare the array of components based on the types */
|
||||
schemaRef.current.fields.forEach((field)=>{
|
||||
@@ -289,8 +291,9 @@ export default function FormView({
|
||||
tabs[group].push(
|
||||
useMemo(()=><MappedFormControl
|
||||
inputRef={(ele)=>{
|
||||
if(firstEleRef && !firstEleRef.current) {
|
||||
if(!firstEleSet.current && ele) {
|
||||
firstEleRef.current = ele;
|
||||
firstEleSet.current = true;
|
||||
}
|
||||
}}
|
||||
state={value}
|
||||
@@ -343,10 +346,6 @@ export default function FormView({
|
||||
fullTabs.push(sqlTabName);
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
firstElement.current && firstElement.current.focus();
|
||||
}, []);
|
||||
|
||||
useEffect(()=>{
|
||||
onTabChange && onTabChange(tabValue, Object.keys(tabs)[tabValue], sqlTabActive);
|
||||
}, [tabValue]);
|
||||
|
||||
Reference in New Issue
Block a user