RAC RadioGroup + React Hook Form #9032
              
                Unanswered
              
          
                  
                    
                      stevegreco
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 1 comment 3 replies
-
| 
         I think you just had the ref going to two places? If I set it to just the first Radio it appears to work as expected? https://stackblitz.com/edit/vitejs-vite-5rnvklm5?file=src%2FApp.tsx  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
I have been trying to hook up all of our form inputs using
react-hook-form, as that is what most of our adopters are using within their apps. I have struggled a little bit with forwarding the correct refs to ensure that RHF can properly manage the focus.The issue I am having with the
RadioGroupis that if I mark it asisRequiredand let RHF handle the validation, usingvalidationBehavior="aria", I am noticing that the RadioGroup does not get focused when you submit the form.I believe the expected behavior is that when you submit, the first invalid form field should get focused.
In my example below, if you just submit the form it will correctly become
invalidwithout any sort of focus. If you comment out thevalidationBehavior="aria"then the focus works correctly, but not the validation.Just kind of curious if anyone has any advice on this type of stuff. I would love to see more detailed docs for each form component on how to integrate with a library like
react-hook-form.https://stackblitz.com/edit/vitejs-vite-4cghepvy?file=src%2FApp.tsx
Beta Was this translation helpful? Give feedback.
All reactions