@@ -2000,6 +2000,161 @@ describe("Validation & Value State", () => {
20002000 . find ( "[ui5-token]" )
20012001 . should ( "have.length" , 1 ) ;
20022002 } ) ;
2003+
2004+ it ( "Clears invalid/incomplete values on focus out when noValidation is not set" , ( ) => {
2005+ cy . mount (
2006+ < >
2007+ < Button id = "btn" > Focus target</ Button >
2008+ < MultiComboBox >
2009+ < MultiComboBoxItem text = "Item 1" > </ MultiComboBoxItem >
2010+ < MultiComboBoxItem text = "Item 2" > </ MultiComboBoxItem >
2011+ </ MultiComboBox >
2012+ </ >
2013+ ) ;
2014+
2015+ cy . get ( "[ui5-multi-combobox]" )
2016+ . as ( "mcb" )
2017+ . realClick ( ) ;
2018+
2019+ cy . get ( "@mcb" )
2020+ . should ( "be.focused" ) ;
2021+
2022+ cy . realType ( "xyz" ) ;
2023+
2024+ cy . get ( "@mcb" )
2025+ . should ( "have.attr" , "value-state" , "Negative" ) ;
2026+
2027+ cy . get ( "@mcb" )
2028+ . shadow ( )
2029+ . find ( "input" )
2030+ . should ( "have.value" , "xyz" ) ;
2031+
2032+ cy . get ( "#btn" )
2033+ . realClick ( )
2034+ . should ( "be.focused" ) ;
2035+
2036+ cy . get ( "@mcb" )
2037+ . shadow ( )
2038+ . find ( "input" )
2039+ . should ( "have.value" , "" ) ;
2040+
2041+ cy . get ( "@mcb" )
2042+ . should ( "have.attr" , "value-state" , "None" ) ;
2043+ } ) ;
2044+
2045+ it ( "Does not clear invalid values on focus out when noValidation is set" , ( ) => {
2046+ cy . mount (
2047+ < >
2048+ < Button id = "btn" > Focus target</ Button >
2049+ < MultiComboBox noValidation >
2050+ < MultiComboBoxItem text = "Item 1" > </ MultiComboBoxItem >
2051+ < MultiComboBoxItem text = "Item 2" > </ MultiComboBoxItem >
2052+ </ MultiComboBox >
2053+ </ >
2054+ ) ;
2055+
2056+ cy . get ( "[ui5-multi-combobox]" )
2057+ . as ( "mcb" )
2058+ . realClick ( ) ;
2059+
2060+ cy . get ( "@mcb" )
2061+ . should ( "be.focused" ) ;
2062+
2063+ cy . realType ( "xyz" ) ;
2064+
2065+ cy . get ( "@mcb" )
2066+ . shadow ( )
2067+ . find ( "input" )
2068+ . should ( "have.value" , "xyz" ) ;
2069+
2070+ cy . get ( "#btn" )
2071+ . realClick ( )
2072+ . should ( "be.focused" ) ;
2073+
2074+ cy . get ( "@mcb" )
2075+ . shadow ( )
2076+ . find ( "input" )
2077+ . should ( "have.value" , "xyz" ) ;
2078+ } ) ;
2079+
2080+ it ( "Does not clear valid/matching values on focus out" , ( ) => {
2081+ cy . mount (
2082+ < >
2083+ < Button id = "btn" > Focus target</ Button >
2084+ < MultiComboBox >
2085+ < MultiComboBoxItem text = "Item 1" > </ MultiComboBoxItem >
2086+ < MultiComboBoxItem text = "Item 2" > </ MultiComboBoxItem >
2087+ </ MultiComboBox >
2088+ </ >
2089+ ) ;
2090+
2091+ cy . get ( "[ui5-multi-combobox]" )
2092+ . as ( "mcb" )
2093+ . realClick ( ) ;
2094+
2095+ cy . get ( "@mcb" )
2096+ . should ( "be.focused" ) ;
2097+
2098+ cy . realType ( "Item" ) ;
2099+
2100+ cy . get ( "@mcb" )
2101+ . shadow ( )
2102+ . find ( "input" )
2103+ . should ( "have.value" , "Item 1" ) ;
2104+
2105+ cy . get ( "#btn" )
2106+ . realClick ( )
2107+ . should ( "be.focused" ) ;
2108+
2109+ cy . get ( "@mcb" )
2110+ . shadow ( )
2111+ . find ( "input" )
2112+ . should ( "have.value" , "Item 1" ) ;
2113+ } ) ;
2114+
2115+ it ( "Preserves selected tokens when clearing invalid input on focus out" , ( ) => {
2116+ cy . mount (
2117+ < >
2118+ < Button id = "btn" > Focus target</ Button >
2119+ < MultiComboBox >
2120+ < MultiComboBoxItem text = "Item 1" selected > </ MultiComboBoxItem >
2121+ < MultiComboBoxItem text = "Item 2" > </ MultiComboBoxItem >
2122+ </ MultiComboBox >
2123+ </ >
2124+ ) ;
2125+
2126+ cy . get ( "[ui5-multi-combobox]" )
2127+ . as ( "mcb" )
2128+ . shadow ( )
2129+ . find ( "[ui5-tokenizer]" )
2130+ . find ( "[ui5-token]" )
2131+ . should ( "have.length" , 1 ) ;
2132+
2133+ cy . get ( "@mcb" )
2134+ . realClick ( ) ;
2135+
2136+ cy . realType ( "xyz" ) ;
2137+
2138+ cy . get ( "@mcb" )
2139+ . shadow ( )
2140+ . find ( "input" )
2141+ . should ( "have.value" , "xyz" ) ;
2142+
2143+ cy . get ( "#btn" )
2144+ . realClick ( )
2145+ . should ( "be.focused" ) ;
2146+
2147+ cy . get ( "@mcb" )
2148+ . shadow ( )
2149+ . find ( "input" )
2150+ . should ( "have.value" , "" ) ;
2151+
2152+ cy . get ( "@mcb" )
2153+ . shadow ( )
2154+ . find ( "[ui5-tokenizer]" )
2155+ . find ( "[ui5-token]" )
2156+ . should ( "have.length" , 1 ) ;
2157+ } ) ;
20032158} ) ;
20042159
20052160describe ( "Keyboard interaction when pressing Ctrl + Alt + F8 for navigation" , ( ) => {
0 commit comments