Fixed Jasmine test cases.

refs #7110
pull/71/head
Nikhil Mohite 2022-02-02 17:55:14 +05:30 committed by Akshay Joshi
parent 23aac4f580
commit 64c419e6f8
3 changed files with 9 additions and 8 deletions

View File

@ -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(()=><MappedFormControl
inputRef={(ele)=>{
if(!firstEleSet.current && ele) {
if(firstEleRef && firstEleID.current === field.id) {
firstEleRef.current = ele;
firstEleSet.current = true;
}
}}
state={value}

View File

@ -559,10 +559,10 @@ InputToggle.propTypes = {
};
export function FormInputToggle({hasError, required, label,
className, helpMessage, testcid, ...props}) {
className, helpMessage, testcid, inputRef, ...props}) {
return (
<FormInput required={required} label={label} error={hasError} className={className} helpMessage={helpMessage} testcid={testcid}>
<InputToggle ref={props.inputRef} {...props}/>
<InputToggle ref={inputRef} {...props}/>
</FormInput>
);
}

View File

@ -14,6 +14,7 @@ const CustomPropTypes = {
ref: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
PropTypes.object
]),
schemaUI: PropTypes.instanceOf(BaseUISchema),