@@ -47,6 +47,33 @@ export class HeaderFilterViewController {
4747 const filterExpression = this . getFilterExpressionWithoutCurrentColumn ( column ) ;
4848 const type = getHeaderFilterListType ( column ) ;
4949 const { columnsController } = this ;
50+ const applyFilter = ( filterValues , filterType ) : void => {
51+ if ( customApply ) {
52+ customApply ( filterValues ) ;
53+ } else {
54+ columnsController . updateColumns (
55+ ( columns ) => {
56+ const index = getColumnIndexByName ( columns , column . name ) ;
57+ const newColumns = [ ...columns ] ;
58+
59+ newColumns [ index ] = {
60+ ...newColumns [ index ] ,
61+ headerFilter : {
62+ ...newColumns [ index ] . headerFilter ,
63+ } ,
64+ // NOTE: Copy array because of mutations in legacy code
65+ filterValues : Array . isArray ( filterValues )
66+ ? [ ...filterValues ]
67+ : filterValues ,
68+ filterType,
69+ } ;
70+ return newColumns ;
71+ } ,
72+ ) ;
73+ }
74+
75+ onFilterCloseCallback ?.( ) ;
76+ } ;
5077 const popupOptions : PopupOptions = {
5178 type,
5279 column : { ...column } ,
@@ -58,31 +85,7 @@ export class HeaderFilterViewController {
5885 ? [ ...column . filterValues ]
5986 : column . filterValues ,
6087 apply ( ) : void {
61- if ( customApply ) {
62- customApply ( this . filterValues ) ;
63- } else {
64- columnsController . updateColumns (
65- ( columns ) => {
66- const index = getColumnIndexByName ( columns , column . name ) ;
67- const newColumns = [ ...columns ] ;
68-
69- newColumns [ index ] = {
70- ...newColumns [ index ] ,
71- headerFilter : {
72- ...newColumns [ index ] . headerFilter ,
73- } ,
74- // NOTE: Copy array because of mutations in legacy code
75- filterValues : Array . isArray ( this . filterValues )
76- ? [ ...this . filterValues ]
77- : this . filterValues ,
78- filterType : this . filterType ,
79- } ;
80- return newColumns ;
81- } ,
82- ) ;
83- }
84-
85- onFilterCloseCallback ?.( ) ;
88+ applyFilter ( this . filterValues , this . filterType ) ;
8689 } ,
8790 hidePopupCallback : ( ) : void => {
8891 this . popupStateInternal . value = null ;
0 commit comments