File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1126,6 +1126,30 @@ describe("UserMenuItem", () => {
11261126 cy . get ( "[ui5-user-menu-item][text='Light']" )
11271127 . should ( "have.attr" , "checked" ) ;
11281128 } ) ;
1129+
1130+ it ( "allows unchecking in single-select mode when showSelection is false" , ( ) => {
1131+ cy . mount (
1132+ < >
1133+ < Button id = "openUserMenuBtn" > Open User Menu</ Button >
1134+ < UserMenu open = { true } opener = "openUserMenuBtn" >
1135+ < UserMenuItem text = "Options" >
1136+ < UserMenuItemGroup checkMode = "Single" >
1137+ < UserMenuItem text = "Opt A" checked = { true } > </ UserMenuItem >
1138+ < UserMenuItem text = "Opt B" > </ UserMenuItem >
1139+ </ UserMenuItemGroup >
1140+ </ UserMenuItem >
1141+ </ UserMenu >
1142+ </ >
1143+ ) ;
1144+
1145+ cy . get ( "[ui5-user-menu]" ) . find ( "[ui5-user-menu-item][text='Options']" ) . as ( "parentItem" ) ;
1146+ cy . get ( "@parentItem" ) . click ( ) ;
1147+
1148+ cy . get ( "[ui5-user-menu-item][text='Opt A']" ) . click ( ) ;
1149+
1150+ cy . get ( "[ui5-user-menu-item][text='Opt A']" )
1151+ . should ( "not.have.attr" , "checked" ) ;
1152+ } ) ;
11291153 } ) ;
11301154
11311155 describe ( "UserMenuItemGroup" , ( ) => {
Original file line number Diff line number Diff line change @@ -61,11 +61,15 @@ class UserMenuItem extends MenuItem {
6161
6262 /**
6363 * Overrides the base MenuItem behavior to prevent unchecking
64- * the currently checked item in single-select mode,
65- * ensuring there is always a selection.
64+ * the currently checked item in single-select mode when
65+ * the parent item uses showSelection, ensuring there is always
66+ * a visible selection.
6667 */
6768 _updateCheckedState ( ) {
68- if ( this . _checkMode === MenuItemGroupCheckMode . Single && this . checked ) {
69+ const parentItem = this . parentElement ?. parentElement ;
70+ const hasShowSelection = parentItem instanceof UserMenuItem && parentItem . showSelection ;
71+
72+ if ( hasShowSelection && this . _checkMode === MenuItemGroupCheckMode . Single && this . checked ) {
6973 return ;
7074 }
7175 super . _updateCheckedState ( ) ;
You can’t perform that action at this time.
0 commit comments