on develop help sign in
Fix initially-checked checkboxes
8be5ac1Ryan Trinkle
src/Reflex/Dom/Widget/Input.hs+2−4
@@ -190,12 +190,10 @@ data Checkbox t
190checkbox :: (DomBuilder t m, PostBuild t m) => Bool -> CheckboxConfig t -> m (Checkbox t)
190checkbox :: (DomBuilder t m, PostBuild t m) => Bool -> CheckboxConfig t -> m (Checkbox t)
191checkbox checked config = do
191checkbox checked config = do
192 let insertType = Map.insert "type" "checkbox"
192 let insertType = Map.insert "type" "checkbox"
193− insertChecked = if checked
194− then Map.insert "checked" "checked"
195− else id
196− dAttrs = fmap (insertChecked . insertType) $ _checkboxConfig_attributes config
193+ dAttrs = fmap (Map.delete "checked" . insertType) $ _checkboxConfig_attributes config
197 modifyAttrs <- dynamicAttributesToModifyAttributes dAttrs
194 modifyAttrs <- dynamicAttributesToModifyAttributes dAttrs
198 i <- inputElement $ def
195 i <- inputElement $ def
196+ & inputElementConfig_initialChecked .~ checked
199 & inputElementConfig_setChecked .~ _checkboxConfig_setValue config
197 & inputElementConfig_setChecked .~ _checkboxConfig_setValue config
200 & inputElementConfig_elementConfig . elementConfig_modifyAttributes .~ modifyAttrs
198 & inputElementConfig_elementConfig . elementConfig_modifyAttributes .~ modifyAttrs
201 return $ Checkbox
199 return $ Checkbox