Closed Orasund closed 3 years ago
@cdevienne The Option Story Story.optionListStory will initiate with the first element of the list, instead of the given default value.
Story.optionListStory
I've therefore decided that we actually see this as a feature and change the function to:
optionListStory : String -> ( String, a ) -> List ( String, a ) -> Story a optionListStory label first options = { info = OptionListStory label <| List.map Tuple.first (first :: options) , toValue = \optLabel -> (first :: options) |> List.foldl (\( key, optvalue ) res -> case ( res, optLabel == key ) of ( Just x, _ ) -> Just x ( Nothing, True ) -> Just optvalue ( Nothing, False ) -> Nothing ) Nothing |> Maybe.withDefault (first |> Tuple.second) }
Note how the default value is now the first element in the list.
I was thinking the exact same thing this morning :-)
@cdevienne The Option Story
Story.optionListStory
will initiate with the first element of the list, instead of the given default value.I've therefore decided that we actually see this as a feature and change the function to:
Note how the default value is now the first element in the list.