For some reason, still not clear to me, calling resetFieldsChanged in the onSubmit event doesn't work as expected. I tried to call it in a useEffect hook that gets executed every time the form state change, and now it works as expected!