@@ -438,12 +438,11 @@ dropdown k0 options (DropdownConfig setK attrs) = do
438 in (Map.fromList $ map snd xs, Bimap.fromList $ map fst xs)
438 in (Map.fromList $ map snd xs, Bimap.fromList $ map fst xs)
439 modifyAttrs <- dynamicAttributesToModifyAttributes attrs
439 modifyAttrs <- dynamicAttributesToModifyAttributes attrs
440 postBuild <- getPostBuild
440 postBuild <- getPostBuild
441− let updatedSelection = attachPromptlyDynWithMaybe (flip Bimap.lookupR) ixKeys setK
441+ let setSelection = attachPromptlyDynWithMaybe (flip Bimap.lookupR) ixKeys $
442− initialSelection = attachPromptlyDynWithMaybe (flip Bimap.lookupR) ixKeys (k0 <$ postBuild)
442+ leftmost [setK, k0 <$ postBuild]
443− selection = leftmost [updatedSelection, initialSelection]
444 let cfg = def
443 let cfg = def
445 & selectElementConfig_elementConfig . elementConfig_modifyAttributes .~ fmap mapKeysToAttributeName modifyAttrs
444 & selectElementConfig_elementConfig . elementConfig_modifyAttributes .~ fmap mapKeysToAttributeName modifyAttrs
446− & selectElementConfig_setValue .~ fmap (T.pack . show) selection
445+ & selectElementConfig_setValue .~ fmap (T.pack . show) setSelection
447 (eRaw, _) <- selectElement cfg $ listWithKey indexedOptions $ \(ix, k) v -> do
446 (eRaw, _) <- selectElement cfg $ listWithKey indexedOptions $ \(ix, k) v -> do
448 let optionAttrs = fmap (\dk -> "value" =: T.pack (show ix) <> if dk == k then "selected" =: "selected" else mempty) defaultKey
447 let optionAttrs = fmap (\dk -> "value" =: T.pack (show ix) <> if dk == k then "selected" =: "selected" else mempty) defaultKey
449 elDynAttr "option" optionAttrs $ dynText v
448 elDynAttr "option" optionAttrs $ dynText v