-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Hello ,
I want to make all the form fields touched, once user moves from one accordion to another, in the given example .
https://codesandbox.io/p/sandbox/react-data-driven-autocomplete-forked-9tkfvt?file=%2Fsrc%2FForm.jsx%3A17%2C26.
The below code does not work . Can anyone please help me if I am doing anything wrong here?
const formOptions = useFormApi();
const {lastOpened, setFormState} = useAppContext();
const {fields} = useFieldsApi(props);
//This if condition is to extract all the fields which were last opened and it is working as expected.
if (fields && fields.length) {
const filteredFieldItems = fields.filter((field:any)=> field.name === lastOpened)
}
if(filteredFieldItems && filtteredFieldItems.length) {
filteredFieldItems[0].fields.forEach((field:any)=> {
formOptions.focus(field.name);
})
}
The line highlighted above does not focus the fields. Is that a correct syntax? I am able to extract the fields .