[Preact, RHF 7.0] Radio inputs not working
See original GitHub issueDescribe the bug
Radio inputs aren’t working correctly in Preact project after upgrading to the latest RHF version.
Only last selected input produces a value, other input values are shown as null
.
To Reproduce Steps to reproduce the behavior:
- Go to the Codesandbox example
- Click on ‘One’, click ‘Submit’
{test: null}
is logged to the console- Click on ‘Three’, click ‘Submit’
{test: "three"}
is logged to the console
Codesandbox link (Required) https://codesandbox.io/s/funny-saha-1dr1e?file=/src/index.js
Expected behavior All radio inputs produce values.
Screenshots N/A
Desktop:
- OS: Windows
- Browser: Edge
- Version: 89
Additional context Not sure if Preact compatibility is something that has any priority, just wanted to report this as it worked in RHF 6.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Radio - preact-material-components
This is a possible example of controlling the values of a group of radio buttons in component state. import { Component } from...
Read more >vpzomtrrfrt/preact-radio-group: Better radio buttons. - GitHub
A few problems: Repetitive fields ( name , type , checked , onChange ). Hard to set the checked value. You need to...
Read more >Radio buttons and checkboxes won't work with Contact form 7 ...
If I insert my form with Contact form 7 Styler my checkboxes and radio buttons don't work. If I insert it with the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@r04423
There is an use case to show/hide input element that needs “document.contains”, while the “detached” DOM element and “not attached yet” DOM element have the same behavior, it’s hard to define a handling for use case of Preact.
I would suggest another workaround to keep using “register” instead of using Controller:
@leapful and @bluebill1049 thank you so much for looking into this!
And indeed, this workaround does seem to work 👍