Make WordPress Core

Ticket #38948: 38948_2.diff

File 38948_2.diff, 1.9 KB (added by delawski, 8 years ago)
  • src/wp-admin/js/customize-nav-menus.js

    diff --git a/src/wp-admin/js/customize-nav-menus.js b/src/wp-admin/js/customize-nav-menus.js
    index be3fba1..52d3a09 100644
    a b  
    10291029                },
    10301030
    10311031                onChangeExpanded: function( expanded, args ) {
    1032                         var section = this;
     1032                        var section = this, completeCallback;
    10331033
    10341034                        if ( expanded ) {
    10351035                                wpNavMenu.menuList = section.contentContainer;
     
    10451045                                        }
    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();
     1048                                // Make sure Sortables is initialized after the section has been expanded to prevent `offset` issues.
     1049                                if ( args.completeCallback ) {
     1050                                        completeCallback = args.completeCallback;
    10541051                                }
     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 );
    10571066                }