From 0549fd553363a317f3481b5011f03ea3513330f9 Mon Sep 17 00:00:00 2001 From: Georgi Hristanov Date: Tue, 6 Oct 2020 20:22:48 +0300 Subject: [PATCH] [FEATURE] sap.ui.unified.MenuItem: HasPopup enumeration consumed Our MenuItem control now uses the newly implemented HasPopup enumeration to indicate for a submenu's presence, instead of hard-coding a string in aria-haspopup. Change-Id: I3debd5566384eab5f988d24c28707549b16097a1 JIRA: BGSOFUIBALKAN-5588 --- src/sap.ui.unified/src/sap/ui/unified/MenuItem.js | 6 +++--- .../test/sap/ui/unified/qunit/MenuItem.qunit.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) 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({