diff --git a/src/sap.ui.unified/src/sap/ui/unified/MenuItem.js b/src/sap.ui.unified/src/sap/ui/unified/MenuItem.js index 8f2917eca586..3adf1cdafb2a 100644 --- a/src/sap.ui.unified/src/sap/ui/unified/MenuItem.js +++ b/src/sap.ui.unified/src/sap/ui/unified/MenuItem.js @@ -3,8 +3,8 @@ */ // Provides control sap.ui.unified.MenuItem. -sap.ui.define(['sap/ui/core/IconPool', './MenuItemBase', './library'], - function(IconPool, MenuItemBase, library) { +sap.ui.define(['sap/ui/core/IconPool', './MenuItemBase', './library', 'sap/ui/core/library'], + function(IconPool, MenuItemBase, library, coreLibrary) { "use strict"; @@ -97,7 +97,7 @@ sap.ui.define(['sap/ui/core/IconPool', './MenuItemBase', './library'], labelledby: {value: /*oMenu.getId() + "-label " + */this.getId() + "-txt " + this.getId() + "-scuttxt", append: true} }); if (oSubMenu) { - rm.attr("aria-haspopup", true); + rm.attr("aria-haspopup", coreLibrary.aria.HasPopup.Menu.toLowerCase()); rm.attr("aria-owns", oSubMenu.getId()); } } diff --git a/src/sap.ui.unified/test/sap/ui/unified/qunit/MenuItem.qunit.js b/src/sap.ui.unified/test/sap/ui/unified/qunit/MenuItem.qunit.js index 6d13130b6d07..fec48663ed67 100644 --- a/src/sap.ui.unified/test/sap/ui/unified/qunit/MenuItem.qunit.js +++ b/src/sap.ui.unified/test/sap/ui/unified/qunit/MenuItem.qunit.js @@ -38,6 +38,21 @@ sap.ui.define([ oLabel.destroy(); }); + QUnit.test("aria-haspopup", function (assert) { + var oMenuItem = new MenuItem({ text: "Plain" }), + oMenuItemWithSubmenu = new MenuItem({ text: "With submenu", submenu: new Menu() }), + oMenu = new Menu({ items: [oMenuItem, oMenuItemWithSubmenu] }); + + oMenu.placeAt("qunit-fixture"); + sap.ui.getCore().applyChanges(); + + oMenu.open(); + assert.notOk(oMenuItem.$().attr("aria-haspopup"), "Menu items don't have aria-haspopup when there's no submenu"); + assert.strictEqual(oMenuItemWithSubmenu.$().attr("aria-haspopup"), "menu", "Submenu presence is indicated in aria-haspopup"); + + oMenu.destroy(); + }); + QUnit.module("Events", { beforeEach: function() { this.oMenuItem = new MenuItem({