on develop help sign in
Push `leftmost` deeper to combine `attachPromptlyDynWithMaybe`
commitdb7e6efabb99d822be627b0d42d1fc9e86367fcb authorJohn Ericson <John.Ericson@Obsidian.Systems> dateThu 2 Jan 2020, 18:13 (7 years ago) parentf81d943
1 file changed+3−4
reflex-dom-core/src/Reflex/Dom/Widget/Input.hs+3−4
reflex-dom-core/src/Reflex/Dom/Widget/Input.hs+3−4
@@ -438,12 +438,11 @@ dropdown k0 options (DropdownConfig setK attrs) = do
438438 in (Map.fromList $ map snd xs, Bimap.fromList $ map fst xs)
439439 modifyAttrs <- dynamicAttributesToModifyAttributes attrs
440440 postBuild <- getPostBuild
441− let updatedSelection = attachPromptlyDynWithMaybe (flip Bimap.lookupR) ixKeys setK
442− initialSelection = attachPromptlyDynWithMaybe (flip Bimap.lookupR) ixKeys (k0 <$ postBuild)
443− selection = leftmost [updatedSelection, initialSelection]
441+ let setSelection = attachPromptlyDynWithMaybe (flip Bimap.lookupR) ixKeys $
442+ leftmost [setK, k0 <$ postBuild]
444443 let cfg = def
445444 & selectElementConfig_elementConfig . elementConfig_modifyAttributes .~ fmap mapKeysToAttributeName modifyAttrs
446− & selectElementConfig_setValue .~ fmap (T.pack . show) selection
445+ & selectElementConfig_setValue .~ fmap (T.pack . show) setSelection
447446 (eRaw, _) <- selectElement cfg $ listWithKey indexedOptions $ \(ix, k) v -> do
448447 let optionAttrs = fmap (\dk -> "value" =: T.pack (show ix) <> if dk == k then "selected" =: "selected" else mempty) defaultKey
449448 elDynAttr "option" optionAttrs $ dynText v