- this.getItems().forEach( function ( item ) {
- if (
- item.isUsingDefaultAsBaseValue() &&
- (
- // This setting can only be applied to these groups
- // the other groups are way too complex for that
- model.getType() === 'single_option' ||
- model.getType() === 'boolean'
- )
- ) {
- // Apply selection
- item.toggleSelected( !!model.defaultFilters[ item.getName() ] );
- }
- } );
+ if ( this.isSticky() ) {
+ $.each( this.defaultFilters, function ( filterName, filterValue ) {
+ model.getItemByName( filterName ).toggleSelected( filterValue );
+ } );
+ }
+
+ // Verify that single_option group has at least one item selected
+ if (
+ this.getType() === 'single_option' &&
+ this.getSelectedItems().length === 0
+ ) {
+ defaultParam = groupDefault !== undefined ?
+ groupDefault : this.getItems()[ 0 ].getParamName();
+
+ // Single option means there must be a single option
+ // selected, so we have to either select the default
+ // or select the first option
+ this.selectItemByParamName( defaultParam );
+ }