Make WordPress Core

Changeset 59139


Ignore:
Timestamp:
09/30/2024 10:20:36 PM (12 days ago)
Author:
joedolson
Message:

Media: Hide sidebar in Create Gallery when no actions available.

Check whether the media frame menu has action items. If not, hide the sidebar. Prevents showing a sidebar that looks interactive but contains no controls that are interactive. When in Create Gallery mode, the only action available is 'Create Gallery', and it is always active.

Props ukdrahul, ababir, ruchirj, nhrrob, joedolson, shailu25, mukesh27, sudipatel007, dhrumilk.
Fixes #60666.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/media/controllers/state.js

    r57691 r59139  
    166166        var menu = this.frame.menu,
    167167            mode = this.get('menu'),
    168             actionMenuItems,
    169             actionMenuLength,
    170             view;
     168            view,
     169            actionMenuItems = this.frame.menu.get('views'),
     170            actionMenuLength = actionMenuItems ? actionMenuItems.views.get().length : 0;
    171171
    172172        if ( this.frame.menu ) {
    173             actionMenuItems = this.frame.menu.get('views'),
    174             actionMenuLength = actionMenuItems ? actionMenuItems.views.get().length : 0,
    175173            // Show action menu only if it is active and has more than one default element.
    176174            this.frame.$el.toggleClass( 'hide-menu', ! mode || actionMenuLength < 2 );
    177175        }
    178         if ( ! mode ) {
     176        if ( ! mode || actionMenuLength < 2 ) {
    179177            return;
    180178        }
Note: See TracChangeset for help on using the changeset viewer.