Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checked property doesn't work correctly for radio inputs #412

Open
kmicklas opened this issue Feb 11, 2021 · 1 comment
Open

Checked property doesn't work correctly for radio inputs #412

kmicklas opened this issue Feb 11, 2021 · 1 comment
Labels

Comments

@kmicklas
Copy link
Contributor

_inputElement_checked and _inputElement_checkedChange don't work properly for input input elements with type radio, because reflex-dom assumes the checkedness will always change in response to a click on the element. However, each radio button is its own input element and selecting one remotely deselects all others within the named group, which reflex-dom doesn't detect.

@kmicklas kmicklas added the bug label Feb 11, 2021
@tellary
Copy link

tellary commented Jul 7, 2024

I've put together the following example to demonstrate this:

{-# LANGUAGE OverloadedStrings #-}

import qualified Data.Text as T
import           Reflex.Dom

main :: IO ()
main = mainWidget bodyElement

bodyElement :: (DomBuilder t m, PostBuild t m) => m ()
bodyElement = do
  radio1 <- inputElement
            $ def
            & inputElementConfig_initialValue .~ "radio1"
            & inputElementConfig_elementConfig
            . elementConfig_initialAttributes .~
            ("type" =: "radio" <> "name" =: "example")
  text " radio1. selected: "
  dynText $ T.pack . show <$> (_inputElement_checked $ radio1)
  el "br" blank

  radio2 <- inputElement
            $ def
            & inputElementConfig_initialValue .~ "radio2"
            & inputElementConfig_elementConfig
            . elementConfig_initialAttributes .~
            ("type" =: "radio" <> "name" =: "example")
  text " radio2. selected: "
  dynText $ T.pack . show <$> (_inputElement_checked $ radio2)
  el "br" blank

  radio3 <- inputElement
            $ def
            & inputElementConfig_initialValue .~ "radio3"
            & inputElementConfig_elementConfig
            . elementConfig_initialAttributes .~
            ("type" =: "radio" <> "name" =: "example")
  text " radio3. selected: "
  dynText $ T.pack . show <$> (_inputElement_checked $ radio3)
  el "br" blank

When I click on "radio1" the UI shows "checked: True" in the same line. When I click "radio2", the UI shows "checked: True" in the second line, but the "checked: True" text remains in the first line.

Any chance this is going to be addressed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants