@@ -384,13 +384,13 @@ describe("Input general interaction", () => {
384384 it ( "tests selection-change with custom items" , ( ) => {
385385 cy . mount (
386386 < 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" />
392392 </ Input >
393- ) ;
393+ ) ;
394394
395395 cy . get ( "ui5-input" )
396396 . as ( "input" ) ;
@@ -435,11 +435,11 @@ describe("Input general interaction", () => {
435435 it ( "Should fire 'input' event when the value is cleared with ESC" , ( ) => {
436436 cy . mount (
437437 < Input > </ Input >
438- ) ;
438+ ) ;
439439
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+ } ) ;
443443
444444 cy . get ( "[ui5-input]" ) . realClick ( ) ;
445445 cy . get ( "[ui5-input]" ) . realPress ( "a" ) ;
@@ -499,13 +499,13 @@ describe("Input arrow navigation", () => {
499499 it ( "Should navigate up and down through the suggestions popover with arrow keys" , ( ) => {
500500 cy . mount (
501501 < 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" />
507507 </ Input >
508- ) ;
508+ ) ;
509509
510510 cy . get ( "#myInput2" )
511511 . as ( "input" ) ;
@@ -551,7 +551,7 @@ describe("Input PAGEUP/PAGEDOWN navigation", () => {
551551 beforeEach ( ( ) => {
552552 cy . mount (
553553 < Input id = "myInput" showSuggestions placeholder = "Search for a country ..." >
554- < SuggestionItemGroup headerText = "A" >
554+ < SuggestionItemGroup headerText = "A" >
555555 < SuggestionItem text = "Afghanistan" />
556556 < SuggestionItem text = "Argentina" />
557557 < SuggestionItem text = "Albania" />
@@ -564,9 +564,9 @@ describe("Input PAGEUP/PAGEDOWN navigation", () => {
564564 < SuggestionItem text = "Azerbaijan" />
565565 < SuggestionItem text = "Aruba" />
566566 < SuggestionItem text = "Antigua and Barbuda" />
567- </ SuggestionItemGroup >
567+ </ SuggestionItemGroup >
568568 </ Input >
569- ) ;
569+ ) ;
570570 } ) ;
571571 it ( "Should focus the tenth item from the suggestions popover with PAGEDOWN" , ( ) => {
572572 cy . get ( "ui5-input" )
@@ -626,11 +626,11 @@ describe("Selection-change event", () => {
626626 it ( "Selection-change event fires with null arguments when suggestion was selected but user alters input value to something else" , ( ) => {
627627 cy . mount (
628628 < 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" />
632632 </ Input >
633- ) ;
633+ ) ;
634634
635635 cy . get ( "ui5-input" )
636636 . as ( "input" ) ;
@@ -676,6 +676,61 @@ describe("Selection-change event", () => {
676676 expect ( eventCount ) . to . equal ( 2 ) ;
677677 } ) ;
678678 } ) ;
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+ } ) ;
679734} ) ;
680735
681736describe ( "Change event behavior when selecting the same suggestion item" , ( ) => {
@@ -684,15 +739,15 @@ describe("Change event behavior when selecting the same suggestion item", () =>
684739 beforeEach ( ( ) => {
685740 cy . mount (
686741 < Input id = "myInput" showSuggestions placeholder = "Search for a country ..." >
687- < SuggestionItemGroup headerText = "A" >
742+ < SuggestionItemGroup headerText = "A" >
688743 < SuggestionItem text = "Afghanistan" />
689744 < SuggestionItem text = "Argentina" />
690745 < SuggestionItem text = "Albania" />
691746 < SuggestionItem text = "Armenia" />
692747 < SuggestionItem text = "Algeria" />
693- </ SuggestionItemGroup >
748+ </ SuggestionItemGroup >
694749 </ Input >
695- ) ;
750+ ) ;
696751
697752 cy . get ( "#myInput" )
698753 . as ( "input" ) ;
0 commit comments