Skip to content
Prev Previous commit
Next Next commit
Enhance Menu Item Rendering: Add in-use state indication and screen r…
…eader text for already added items
  • Loading branch information
AKSHAT2802 committed Jul 22, 2025
commit ebe219ea778013dfa8b6146911ab62a924652205
17 changes: 13 additions & 4 deletions src/js/_enqueues/wp/customize/nav-menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,20 @@

renderMenuItem: function(menuItem) {
var $item = $(wp.template('available-menu-item')(menuItem.attributes));
var $title = $item.find('.menu-item-title');
var $button = $item.find('.item-add');
var $srtext = $button.find('.screen-reader-text');
var isInUse = this.isMenuItemAlreadyAdded(menuItem);

$item.find('.menu-item-title').toggleClass(
'in-use',
this.isMenuItemAlreadyAdded(menuItem)
);
$title.toggleClass('in-use', isInUse);

// Append screen reader text if already in menu
if (isInUse) {
var markerText = wp.i18n.__('(in current menu)');
if (!$srtext.text().includes(markerText)) {
$srtext.append(' ' + markerText);
}
}

return $item;
},
Expand Down
Loading