Merge pull request #16486 from woocommerce/fix/16317
Sort multiselects alphabetically
This commit is contained in:
commit
38ac7e4ac0
File diff suppressed because one or more lines are too long
|
@ -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
Loading…
Reference in New Issue