Skip to content

Commit e316f48

Browse files
Phil Freemanmaddie927
authored andcommitted
Form select component should use the label in readonly mode (#91)
I use toString for the equality test here, so that this can be a non-breaking change (in terms of the API anyway)
1 parent a56b99e commit e316f48

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Lumi/Components/Form.purs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,12 @@ select
466466
select toString fromString opts = formBuilder_ \{ readonly } selected onChange ->
467467
if readonly
468468
then
469-
Input.alignToInput $ R.text (maybe "" toString selected)
469+
let toLabel a =
470+
Array.findMap (\{ label, value } ->
471+
if toString value == toString a
472+
then Just label
473+
else Nothing) opts
474+
in Input.alignToInput $ R.text (fromMaybe "" (selected >>= toLabel))
470475
else
471476
NativeSelect.nativeSelect NativeSelect.defaults
472477
{ options = { label: "Select an option ...", value: "" } : map (\{ label, value } -> { label, value: toString value }) opts

0 commit comments

Comments
 (0)