@@ -398,8 +398,8 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
398398 * @hidden @internal
399399 */
400400 public get applyButtonDisabled ( ) : boolean {
401- return ( this . _selectAllItem && ! this . _selectAllItem . isSelected && ! this . _selectAllItem . indeterminate ) ||
402- ( this . displayedListData && this . displayedListData . length === 0 ) ;
401+ return ( ( this . _selectAllItem && ! this . _selectAllItem . isSelected && ! this . _selectAllItem . indeterminate ) ||
402+ ( this . displayedListData && this . displayedListData . length === 0 ) ) && ! this . _addToCurrentFilterItem ?. isSelected ;
403403 }
404404
405405 /**
@@ -528,11 +528,29 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
528528
529529 selectedItems = this . _hierarchicalSelectedItems ;
530530 } else {
531- const item = this . displayedListData [ 1 ] ;
532- const addToCurrentFilterOptionVisible = item === this . addToCurrentFilterItem ;
533- selectedItems = addToCurrentFilterOptionVisible && item . isSelected ?
534- this . esf . listData . slice ( 1 , this . esf . listData . length ) . filter ( el => el . isSelected || el . isFiltered ) :
535- this . esf . listData . slice ( 1 , this . esf . listData . length ) . filter ( el => el . isSelected ) ;
531+ const addToCurrentFilter = this . _addToCurrentFilterItem ?. isSelected ;
532+ const displayedSet = new Set ( this . displayedListData ) ;
533+ const listData = this . esf . listData ;
534+
535+ for ( let i = 1 ; i < listData . length ; i ++ ) {
536+ const el = listData [ i ] ;
537+ const isDisplayed = displayedSet . has ( el ) ;
538+
539+ if ( isDisplayed ) {
540+ // Visible items: only include if selected
541+ if ( el . isSelected ) {
542+ selectedItems . push ( el ) ;
543+ }
544+ } else if ( addToCurrentFilter ) {
545+ // Hidden items with "add to current filter": include if selected or filtered
546+ if ( el . isSelected || el . isFiltered ) {
547+ selectedItems . push ( el ) ;
548+ }
549+ } else if ( el . isSelected ) {
550+ // Hidden items without "add to current filter": include if selected
551+ selectedItems . push ( el ) ;
552+ }
553+ }
536554 }
537555
538556 let unselectedItem ;
0 commit comments