22import '@ts/ui/list/modules/m_search' ;
33import '@ts/ui/list/modules/m_selection' ;
44
5+ import type { ChangedOptionInfo } from '@js/common/core/events' ;
56import messageLocalization from '@js/common/core/localization/message' ;
67import $ from '@js/core/renderer' ;
78import type { DeferredObj } from '@js/core/utils/deferred' ;
@@ -15,6 +16,7 @@ import Popup from '@js/ui/popup/ui.popup';
1516import TreeView from '@js/ui/tree_view' ;
1617import Modules from '@ts/grids/grid_core/m_modules' ;
1718import type { ModuleType } from '@ts/grids/grid_core/m_types' ;
19+ import type TextBox from '@ts/ui/text_box/m_text_box' ;
1820
1921import gridCoreUtils from '../m_utils' ;
2022
@@ -329,24 +331,52 @@ export class HeaderFilterView extends Modules.View {
329331 } ,
330332 } ;
331333
332- function onOptionChanged ( e ) {
333- // T835492, T833015
334- if ( e . fullName === 'searchValue' && needShowSelectAllCheckbox && that . option ( 'headerFilter.hideSelectAllOnSearch' ) !== false ) {
335- if ( options . type === 'tree' ) {
336- e . component . option ( 'showCheckBoxesMode' , e . value ? 'normal' : 'selectAll' ) ;
337- } else {
338- e . component . option ( 'selectionMode' , e . value ? 'multiple' : 'all' ) ;
339- }
334+ const shouldChangeSelectAllCheckBoxVisibility = ( ) : boolean => needShowSelectAllCheckbox
335+ && that . option ( 'headerFilter.hideSelectAllOnSearch' ) !== false ;
336+
337+ const onTreeViewOptionChanged = (
338+ event : ChangedOptionInfo & {
339+ component : TreeView & { _searchEditor : TextBox } ;
340+ } ,
341+ ) : void => {
342+ switch ( true ) {
343+ case event . fullName === 'searchValue' && shouldChangeSelectAllCheckBoxVisibility ( ) :
344+ event . component . option ( 'showCheckBoxesMode' , event . value ? 'normal' : 'selectAll' ) ;
345+ break ;
346+ // TODO TreeView: remove this WA after Navigation squad re-render fix
347+ // NOTE: WA for TreeView re-render after changing the "showCheckBoxesMode" option
348+ // After this option change the whole TreeView re-render and search input loose the focus
349+ case event . fullName === 'showCheckBoxesMode' :
350+ // NOTE: the TreeView render is async
351+ // So we should focus the searchEditor only after render will be completed
352+ Promise . resolve ( )
353+ . then ( ( ) => {
354+ event . component . _searchEditor . focus ( ) ;
355+ } )
356+ . catch ( ( ) => { } ) ;
357+ break ;
358+ default :
359+ break ;
340360 }
341- }
361+ } ;
362+
363+ const onListOptionChanged = (
364+ event : ChangedOptionInfo & {
365+ component : dxList ;
366+ } ,
367+ ) : void => {
368+ if ( event . fullName === 'searchValue' && shouldChangeSelectAllCheckBoxVisibility ( ) ) {
369+ event . component . option ( 'selectionMode' , event . value ? 'multiple' : 'all' ) ;
370+ }
371+ } ;
342372
343373 if ( options . type === 'tree' ) {
344374 that . _listComponent = that . _createComponent (
345375 $ ( '<div>' ) . appendTo ( $content ) ,
346376 TreeView ,
347377 extend ( widgetOptions , {
348378 showCheckBoxesMode : needShowSelectAllCheckbox ? 'selectAll' : 'normal' ,
349- onOptionChanged,
379+ onOptionChanged : onTreeViewOptionChanged ,
350380 keyExpr : 'id' ,
351381 } ) ,
352382 ) ;
@@ -359,7 +389,7 @@ export class HeaderFilterView extends Modules.View {
359389 pageLoadMode : 'scrollBottom' ,
360390 showSelectionControls : true ,
361391 selectionMode : needShowSelectAllCheckbox ? 'all' : 'multiple' ,
362- onOptionChanged,
392+ onOptionChanged : onListOptionChanged ,
363393 onSelectionChanged ( event ) {
364394 const { component : listComponent } = event ;
365395 const items = listComponent . option ( 'items' ) ;
0 commit comments