Ensure that cursor should be focused on the first options of the Utility dialogs. Fixes #7110

This commit is contained in:
Nikhil Mohite
2022-02-02 14:48:35 +05:30
committed by Akshay Joshi
parent 4d727015fd
commit b4b658c59d
4 changed files with 23 additions and 21 deletions

View File

@@ -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]);