@@ -1107,8 +1107,8 @@ defmodule LiveSelectTest do
11071107 end
11081108 end
11091109
1110- test "handles nil in options list when navigating and clearing input " , % { conn: conn } do
1111- stub_options ( [ { "A" , 1 } , { "B" , 2 } , { "C" , 3 } ] )
1110+ test "handles hitting enter after options have been cleared " , % { conn: conn } do
1111+ stub_options ( [ "A" , "B" , "C" ] )
11121112
11131113 { :ok , live , _html } = live ( conn , "/" )
11141114
@@ -1125,4 +1125,34 @@ defmodule LiveSelectTest do
11251125
11261126 refute_selected ( live )
11271127 end
1128+
1129+ test "handles hitting enter after options have been cleared and something was previously selected" ,
1130+ % {
1131+ conn: conn
1132+ } do
1133+ stub_options ( [ "A" , "B" , "C" ] )
1134+
1135+ { :ok , live , _html } = live ( conn , "/" )
1136+
1137+ type ( live , "ABC" )
1138+
1139+ assert_options ( live , [ "A" , "B" , "C" ] )
1140+
1141+ select_nth_option ( live , 2 )
1142+
1143+ assert_selected ( live , "B" )
1144+
1145+ type ( live , "ABC" )
1146+
1147+ assert_options ( live , [ "A" , "B" , "C" ] )
1148+
1149+ keydown ( live , "ArrowDown" )
1150+ keydown ( live , "Backspace" )
1151+
1152+ type ( live , "" )
1153+
1154+ keydown ( live , "Enter" )
1155+
1156+ assert_selected_static ( live , "B" )
1157+ end
11281158end
0 commit comments