From 64c419e6f80106514cc62d9e3cdb2c4416d7eb38 Mon Sep 17 00:00:00 2001 From: Nikhil Mohite Date: Wed, 2 Feb 2022 17:55:14 +0530 Subject: [PATCH] Fixed Jasmine test cases. refs #7110 --- web/pgadmin/static/js/SchemaView/FormView.jsx | 12 ++++++------ web/pgadmin/static/js/components/FormComponents.jsx | 4 ++-- web/pgadmin/static/js/custom_prop_types.js | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/web/pgadmin/static/js/SchemaView/FormView.jsx b/web/pgadmin/static/js/SchemaView/FormView.jsx index bd2c2064f..3d90f03e0 100644 --- a/web/pgadmin/static/js/SchemaView/FormView.jsx +++ b/web/pgadmin/static/js/SchemaView/FormView.jsx @@ -150,7 +150,7 @@ export default function FormView({ let tabsClassname = {}; const [tabValue, setTabValue] = useState(0); const classes = useStyles(); - const firstEleSet = useRef(); + const firstEleID = useRef(); const formRef = useRef(); const onScreenTracker = useRef(false); const depListener = useContext(DepListenerContext); @@ -201,8 +201,6 @@ 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)=>{ @@ -287,13 +285,15 @@ export default function FormView({ } const id = field.id || `control${tabs[group].length}`; - + if(visible && !disabled && !firstEleID.current) { + firstEleID.current = field.id; + } + tabs[group].push( useMemo(()=>{ - if(!firstEleSet.current && ele) { + if(firstEleRef && firstEleID.current === field.id) { firstEleRef.current = ele; - firstEleSet.current = true; } }} state={value} diff --git a/web/pgadmin/static/js/components/FormComponents.jsx b/web/pgadmin/static/js/components/FormComponents.jsx index 09604c00d..4deea23f4 100644 --- a/web/pgadmin/static/js/components/FormComponents.jsx +++ b/web/pgadmin/static/js/components/FormComponents.jsx @@ -559,10 +559,10 @@ InputToggle.propTypes = { }; export function FormInputToggle({hasError, required, label, - className, helpMessage, testcid, ...props}) { + className, helpMessage, testcid, inputRef, ...props}) { return ( - + ); } diff --git a/web/pgadmin/static/js/custom_prop_types.js b/web/pgadmin/static/js/custom_prop_types.js index d2ce556a0..7ec2cda8c 100644 --- a/web/pgadmin/static/js/custom_prop_types.js +++ b/web/pgadmin/static/js/custom_prop_types.js @@ -14,6 +14,7 @@ const CustomPropTypes = { ref: PropTypes.oneOfType([ PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(Element) }), + PropTypes.object ]), schemaUI: PropTypes.instanceOf(BaseUISchema),