Fix simulateClickOption not working when mutliple options contain the same substring

This commit is contained in:
Tom Nunn 2022-07-13 12:24:55 +02:00
parent 0671e3c3ce
commit e21bfc3e50
4 changed files with 2 additions and 7 deletions

View File

@ -68,8 +68,6 @@ simulateInputConfig =
{ simulateDomEvent = ProgramTest.simulateDomEvent
, find = Query.find
, attribute = Selector.attribute
, containing = Selector.containing
, text = Selector.text
}

View File

@ -99,8 +99,6 @@ simulateConfig =
{ simulateDomEvent = ProgramTest.simulateDomEvent
, find = Query.find
, attribute = Selector.attribute
, containing = Selector.containing
, text = Selector.text
}

View File

@ -235,6 +235,7 @@ optionElement v i opt =
Element.row
[ Element.htmlAttribute (Html.Attributes.id (v.toOptionId i))
, htmlAttribute "role" "option"
, htmlAttribute "value" (Option.toString opt)
, Element.htmlAttribute (Html.Events.preventDefaultOn "mousedown" (Decode.succeed ( v.onChange NoOp, True )))
, Element.htmlAttribute (Html.Events.preventDefaultOn "click" (Decode.succeed ( v.onChange <| OptionClicked opt, True )))
, Events.onMouseEnter (v.onChange <| MouseEnteredOption i)

View File

@ -281,8 +281,6 @@ type alias SimulateInputConfig single selector programTest =
{ simulateDomEvent : (single -> single) -> ( String, Encode.Value ) -> programTest -> programTest
, find : List selector -> single -> single
, attribute : Html.Attribute Never -> selector
, containing : List selector -> selector
, text : String -> selector
}
@ -315,7 +313,7 @@ simulateClickOption config id optionLabel =
(config.find [ config.attribute (Html.Attributes.id (id ++ "-menu")) ]
>> config.find
[ config.attribute (Html.Attributes.attribute "role" "option")
, config.containing [ config.text optionLabel ]
, config.attribute (Html.Attributes.attribute "value" optionLabel)
]
)
( "click", Encode.object [] )