WordPress.org

Make WordPress Core

Changeset 39376


Ignore:
Timestamp:
11/30/2016 05:42:05 PM (3 years ago)
Author:
westonruter
Message:

Customize: Fix regression in ability to create submenus for nav menus via drag and drop.

See #34391.
Fixes #38948.
Props delawski, adamsilverstein.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-nav-menus.js

    r39345 r39376  
    10301030
    10311031        onChangeExpanded: function( expanded, args ) {
    1032             var section = this;
     1032            var section = this, completeCallback;
    10331033
    10341034            if ( expanded ) {
     
    10461046                } );
    10471047
    1048                 if ( 'resolved' !== section.deferred.initSortables.state() ) {
    1049                     wpNavMenu.initSortables(); // Depends on menu-to-edit ID being set above.
    1050                     section.deferred.initSortables.resolve( wpNavMenu.menuList ); // Now MenuControl can extend the sortable.
    1051 
    1052                     // @todo Note that wp.customize.reflowPaneContents() is debounced, so this immediate change will show a slight flicker while priorities get updated.
    1053                     api.control( 'nav_menu[' + String( section.params.menu_id ) + ']' ).reflowMenuItems();
    1054                 }
     1048                // Make sure Sortables is initialized after the section has been expanded to prevent `offset` issues.
     1049                if ( args.completeCallback ) {
     1050                    completeCallback = args.completeCallback;
     1051                }
     1052                args.completeCallback = function() {
     1053                    if ( 'resolved' !== section.deferred.initSortables.state() ) {
     1054                        wpNavMenu.initSortables(); // Depends on menu-to-edit ID being set above.
     1055                        section.deferred.initSortables.resolve( wpNavMenu.menuList ); // Now MenuControl can extend the sortable.
     1056
     1057                        // @todo Note that wp.customize.reflowPaneContents() is debounced, so this immediate change will show a slight flicker while priorities get updated.
     1058                        api.control( 'nav_menu[' + String( section.params.menu_id ) + ']' ).reflowMenuItems();
     1059                    }
     1060                    if ( _.isFunction( completeCallback ) ) {
     1061                        completeCallback();
     1062                    }
     1063                };
    10551064            }
    10561065            api.Section.prototype.onChangeExpanded.call( section, expanded, args );
Note: See TracChangeset for help on using the changeset viewer.