Merge pull request #16486 from woocommerce/fix/16317

Sort multiselects alphabetically
This commit is contained in:
Mike Jolley 2017-08-21 18:19:55 +01:00 committed by GitHub
commit 38ac7e4ac0
3 changed files with 20 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -131,6 +131,24 @@ jQuery( function( $ ) {
} ); } );
} }
}); });
// Keep multiselects ordered alphabetically if they are not sortable.
} else if ( $( this ).prop( 'multiple' ) ) {
$( this ).on( 'change', function(){
var $children = $( this ).children();
$children.sort(function(a, b){
var atext = a.text.toLowerCase();
var btext = b.text.toLowerCase();
if (atext > btext) {
return 1;
}
if (atext < btext) {
return -1;
}
return 0;
});
$( this ).html( $children );
});
} }
}); });

File diff suppressed because one or more lines are too long