File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
testing/tests/DevExpress.ui.widgets Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -1045,7 +1045,7 @@ class Menu extends MenuBase {
10451045
10461046 unselectItem ( itemElement ) : void {
10471047 this . _hideSubmenu ( this . _visibleSubmenu ) ;
1048- super . selectItem ( itemElement ) ;
1048+ super . unselectItem ( itemElement ) ;
10491049 }
10501050}
10511051
Original file line number Diff line number Diff line change @@ -1179,6 +1179,41 @@ QUnit.module('Menu - selection', {
11791179 assert . equal ( $items . find ( '.' + DX_MENU_ITEM_TEXT_CLASS ) . text ( ) , 'item3' ) ;
11801180 } ) ;
11811181
1182+ QUnit . test ( 'should be able to select an item via .selectItem() (T1253750)' , function ( assert ) {
1183+ const menu = createMenu ( {
1184+ items : [
1185+ {
1186+ text : 'menu item 1' ,
1187+ selectable : true ,
1188+ } ,
1189+ ] ,
1190+ } ) ;
1191+ const item = $ ( menu . element ) . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 0 ) ;
1192+
1193+ menu . instance . selectItem ( item [ 0 ] ) ;
1194+
1195+ assert . strictEqual ( item . hasClass ( DX_MENU_ITEM_SELECTED_CLASS ) , true , 'item has the selected class after initialization' ) ;
1196+ } ) ;
1197+
1198+ QUnit . test ( 'should be able to unselect currently selected item (T1253750)' , function ( assert ) {
1199+ const menu = createMenu ( {
1200+ items : [
1201+ {
1202+ text : 'menu item 1' ,
1203+ selectable : true ,
1204+ selected : true ,
1205+ } ,
1206+ ] ,
1207+ } ) ;
1208+ const item = $ ( menu . element ) . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 0 ) ;
1209+
1210+ assert . strictEqual ( item . hasClass ( DX_MENU_ITEM_SELECTED_CLASS ) , true , 'item has the selected class after initialization' ) ;
1211+
1212+ menu . instance . unselectItem ( item [ 0 ] ) ;
1213+
1214+ assert . strictEqual ( item . hasClass ( DX_MENU_ITEM_SELECTED_CLASS ) , false , 'item does not have the selected class after unselecting' ) ;
1215+ } ) ;
1216+
11821217 QUnit . test ( 'Selection in different submenus' , function ( assert ) {
11831218 const items = [
11841219 { text : 'root1' , items : [ { text : 'item1-1' } ] } ,
You can’t perform that action at this time.
0 commit comments