Media: Prevent Media Library sidebar from showing with no actions.

Fix an issue where the actions sidebar in the media library could appear when there are no relevant actions available.

Props sruthi89, nithi22, ivanzhuck, dhruvishah2203, joemcgill, ukdrahul, joedolson, shailu25.
Fixes #58973.

git-svn-id: https://develop.svn.wordpress.org/trunk@57688 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Dolson 2024-02-21 19:44:17 +00:00
parent c2cca0dcfc
commit a138b23bc6

View File

@ -165,9 +165,12 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype
_menu: function() {
var menu = this.frame.menu,
mode = this.get('menu'),
actionMenuItems = this.frame.menu.get('views'),
actionMenuLength = actionMenuItems ? actionMenuItems.views.get().length : 0,
view;
this.frame.$el.toggleClass( 'hide-menu', ! mode );
// Show action menu only if it is active and has more than one default element.
this.frame.$el.toggleClass( 'hide-menu', ! mode || actionMenuLength < 2 );
if ( ! mode ) {
return;
}