Change position fixed element width

This commit is contained in:
Tom Nunn 2022-07-14 22:20:22 +02:00
parent b47a40d9c4
commit d04c817447

View File

@ -115,7 +115,6 @@ toElement_ placement filteredOptions model config =
, menuOpen = Model.isOpen model , menuOpen = Model.isOpen model
, options = filteredOptions , options = filteredOptions
, optionElement = config.optionElement , optionElement = config.optionElement
, positionFixed = config.positionFixed
} }
] ]
++ (if Model.isOpen model then ++ (if Model.isOpen model then
@ -197,20 +196,13 @@ menuView :
, menuOpen : Bool , menuOpen : Bool
, options : List (Option a) , options : List (Option a)
, optionElement : OptionState -> a -> Element msg , optionElement : OptionState -> a -> Element msg
, positionFixed : Bool
} }
-> Element msg -> Element msg
menuView attribs v = menuView attribs v =
List.indexedMap (optionElement v) v.options List.indexedMap (optionElement v) v.options
|> Element.column (attribs ++ [ Element.htmlAttribute <| Html.Attributes.id v.menuId ]) |> Element.column (attribs ++ [ Element.htmlAttribute <| Html.Attributes.id v.menuId ])
|> Element.el |> Element.el
(Element.width (Element.width Element.fill
(if v.positionFixed then
Element.fill
else
Element.shrink
)
:: (if v.menuOpen && List.length v.options > 0 then :: (if v.menuOpen && List.length v.options > 0 then
[] []
@ -299,10 +291,8 @@ defaultMenuAttrs { menuWidth, maxWidth, menuHeight } =
positionFixedEl : Placement -> Maybe Dom.Element -> Element msg -> Element msg positionFixedEl : Placement -> Maybe Dom.Element -> Element msg -> Element msg
positionFixedEl placement container = positionFixedEl placement container =
Element.el Element.el
([ style "position" "fixed" (style "position" "fixed"
, Element.width Element.fill :: (if placement == Placement.Above then
]
++ (if placement == Placement.Above then
[ style "transform" [ style "transform"
("translateY(calc(-100% - 5px - " ("translateY(calc(-100% - 5px - "
++ (Maybe.map (.element >> .height >> String.fromFloat) container |> Maybe.withDefault "0") ++ (Maybe.map (.element >> .height >> String.fromFloat) container |> Maybe.withDefault "0")