@@ -384,13 +384,13 @@ describe("Input general interaction", () => {
384
384
it ( "tests selection-change with custom items" , ( ) => {
385
385
cy . mount (
386
386
< Input id = "myInput2" showSuggestions class = "input3auto" >
387
- < SuggestionItem text = "Cozy" />
388
- < SuggestionItem text = "Compact" />
389
- < SuggestionItem text = "Condensed" />
390
- < SuggestionItem text = "Compact" />
391
- < SuggestionItem text = "Condensed" />
387
+ < SuggestionItem text = "Cozy" />
388
+ < SuggestionItem text = "Compact" />
389
+ < SuggestionItem text = "Condensed" />
390
+ < SuggestionItem text = "Compact" />
391
+ < SuggestionItem text = "Condensed" />
392
392
</ Input >
393
- ) ;
393
+ ) ;
394
394
395
395
cy . get ( "ui5-input" )
396
396
. as ( "input" ) ;
@@ -435,11 +435,11 @@ describe("Input general interaction", () => {
435
435
it ( "Should fire 'input' event when the value is cleared with ESC" , ( ) => {
436
436
cy . mount (
437
437
< Input > </ Input >
438
- ) ;
438
+ ) ;
439
439
440
- cy . get ( "[ui5-input]" ) . then ( $input => {
441
- $input [ 0 ] . addEventListener ( "ui5-input" , cy . spy ( ) . as ( "inputEvent" ) ) ;
442
- } ) ;
440
+ cy . get ( "[ui5-input]" ) . then ( $input => {
441
+ $input [ 0 ] . addEventListener ( "ui5-input" , cy . spy ( ) . as ( "inputEvent" ) ) ;
442
+ } ) ;
443
443
444
444
cy . get ( "[ui5-input]" ) . realClick ( ) ;
445
445
cy . get ( "[ui5-input]" ) . realPress ( "a" ) ;
@@ -499,13 +499,13 @@ describe("Input arrow navigation", () => {
499
499
it ( "Should navigate up and down through the suggestions popover with arrow keys" , ( ) => {
500
500
cy . mount (
501
501
< Input id = "myInput2" showSuggestions class = "input3auto" >
502
- < SuggestionItem text = "Cozy" />
503
- < SuggestionItem text = "Compact" />
504
- < SuggestionItem text = "Condensed" />
505
- < SuggestionItem text = "Compact" />
506
- < SuggestionItem text = "Condensed" />
502
+ < SuggestionItem text = "Cozy" />
503
+ < SuggestionItem text = "Compact" />
504
+ < SuggestionItem text = "Condensed" />
505
+ < SuggestionItem text = "Compact" />
506
+ < SuggestionItem text = "Condensed" />
507
507
</ Input >
508
- ) ;
508
+ ) ;
509
509
510
510
cy . get ( "#myInput2" )
511
511
. as ( "input" ) ;
@@ -551,7 +551,7 @@ describe("Input PAGEUP/PAGEDOWN navigation", () => {
551
551
beforeEach ( ( ) => {
552
552
cy . mount (
553
553
< Input id = "myInput" showSuggestions placeholder = "Search for a country ..." >
554
- < SuggestionItemGroup headerText = "A" >
554
+ < SuggestionItemGroup headerText = "A" >
555
555
< SuggestionItem text = "Afghanistan" />
556
556
< SuggestionItem text = "Argentina" />
557
557
< SuggestionItem text = "Albania" />
@@ -564,9 +564,9 @@ describe("Input PAGEUP/PAGEDOWN navigation", () => {
564
564
< SuggestionItem text = "Azerbaijan" />
565
565
< SuggestionItem text = "Aruba" />
566
566
< SuggestionItem text = "Antigua and Barbuda" />
567
- </ SuggestionItemGroup >
567
+ </ SuggestionItemGroup >
568
568
</ Input >
569
- ) ;
569
+ ) ;
570
570
} ) ;
571
571
it ( "Should focus the tenth item from the suggestions popover with PAGEDOWN" , ( ) => {
572
572
cy . get ( "ui5-input" )
@@ -626,11 +626,11 @@ describe("Selection-change event", () => {
626
626
it ( "Selection-change event fires with null arguments when suggestion was selected but user alters input value to something else" , ( ) => {
627
627
cy . mount (
628
628
< Input id = "input-selection-change" showSuggestions >
629
- < SuggestionItem text = "Cozy" />
630
- < SuggestionItem text = "Compact" />
631
- < SuggestionItem text = "Condensed" />
629
+ < SuggestionItem text = "Cozy" />
630
+ < SuggestionItem text = "Compact" />
631
+ < SuggestionItem text = "Condensed" />
632
632
</ Input >
633
- ) ;
633
+ ) ;
634
634
635
635
cy . get ( "ui5-input" )
636
636
. as ( "input" ) ;
@@ -676,6 +676,61 @@ describe("Selection-change event", () => {
676
676
expect ( eventCount ) . to . equal ( 2 ) ;
677
677
} ) ;
678
678
} ) ;
679
+
680
+ it ( "Fires selection-change when same item is reselected after input is changed" , ( ) => {
681
+ cy . mount (
682
+ < Input id = "input-selection-change" showSuggestions >
683
+ < SuggestionItem text = "Cozy" />
684
+ < SuggestionItem text = "Compact" />
685
+ < SuggestionItem text = "Condensed" />
686
+ </ Input >
687
+ ) ;
688
+
689
+ cy . get ( "ui5-input" )
690
+ . as ( "input" ) ;
691
+
692
+ cy . get ( "ui5-input" )
693
+ . shadow ( )
694
+ . find ( "input" )
695
+ . as ( "innerInput" ) ;
696
+
697
+ cy . get ( "@input" ) . then ( $input => { $input [ 0 ] . addEventListener ( "ui5-selection-change" , cy . stub ( ) . as ( "inputSelectionChange" ) ) ; } ) ;
698
+
699
+ cy . get ( "@innerInput" )
700
+ . realClick ( ) ;
701
+
702
+ cy . get ( "[ui5-suggestion-item" )
703
+ . eq ( 0 )
704
+ . as ( "suggestion-item" ) ;
705
+
706
+ cy . get ( "@innerInput" )
707
+ . type ( "C" ) ;
708
+
709
+ cy . get ( "@suggestion-item" )
710
+ . realClick ( ) ;
711
+
712
+ cy . get ( "@inputSelectionChange" ) . should ( "have.been.calledOnce" ) ;
713
+
714
+ cy . get ( "@innerInput" )
715
+ . should ( "have.value" , "Cozy" ) ;
716
+
717
+ cy . get ( "@innerInput" )
718
+ . realClick ( ) ;
719
+ cy . get ( "@innerInput" )
720
+ . clear ( ) ;
721
+
722
+ cy . get ( "@inputSelectionChange" ) . should ( "have.been.calledTwice" ) ;
723
+
724
+ cy . get ( "@innerInput" )
725
+ . type ( "C" ) ;
726
+ cy . get ( "@suggestion-item" )
727
+ . realClick ( ) ;
728
+
729
+ cy . get ( "@inputSelectionChange" ) . should ( "have.been.calledThrice" ) ;
730
+
731
+ cy . get ( "@innerInput" )
732
+ . should ( "have.value" , "Cozy" ) ;
733
+ } ) ;
679
734
} ) ;
680
735
681
736
describe ( "Change event behavior when selecting the same suggestion item" , ( ) => {
@@ -684,15 +739,15 @@ describe("Change event behavior when selecting the same suggestion item", () =>
684
739
beforeEach ( ( ) => {
685
740
cy . mount (
686
741
< Input id = "myInput" showSuggestions placeholder = "Search for a country ..." >
687
- < SuggestionItemGroup headerText = "A" >
742
+ < SuggestionItemGroup headerText = "A" >
688
743
< SuggestionItem text = "Afghanistan" />
689
744
< SuggestionItem text = "Argentina" />
690
745
< SuggestionItem text = "Albania" />
691
746
< SuggestionItem text = "Armenia" />
692
747
< SuggestionItem text = "Algeria" />
693
- </ SuggestionItemGroup >
748
+ </ SuggestionItemGroup >
694
749
</ Input >
695
- ) ;
750
+ ) ;
696
751
697
752
cy . get ( "#myInput" )
698
753
. as ( "input" ) ;
0 commit comments