@@ -13,7 +13,7 @@ import { IToggleView } from '../core/navigation';
1313import { IBaseCancelableBrowserEventArgs , IBaseEventArgs } from '../core/utils' ;
1414import { IgxOverlayOutletDirective } from '../directives/toggle/toggle.directive' ;
1515import { OverlaySettings } from '../services/overlay/utilities' ;
16- import { IgxPickerToggleComponent } from './picker-icons.common' ;
16+ import { IgxPickerClearComponent , IgxPickerToggleComponent } from './picker-icons.common' ;
1717import { PickerHeaderOrientation , PickerInteractionMode } from './types' ;
1818import { WEEKDAYS } from '../calendar/calendar' ;
1919import { DateRange } from '../date-range-picker/date-range-picker-inputs.common' ;
@@ -261,6 +261,10 @@ export abstract class PickerBaseDirective implements IToggleView, EditorProvider
261261 @ContentChildren ( IgxPickerToggleComponent , { descendants : true } )
262262 public toggleComponents : QueryList < IgxPickerToggleComponent > ;
263263
264+ /** @hidden @internal */
265+ @ContentChildren ( IgxPickerClearComponent , { descendants : true } )
266+ public clearComponents : QueryList < IgxPickerClearComponent > ;
267+
264268 @ContentChildren ( IgxPrefixDirective , { descendants : true } )
265269 protected prefixes : QueryList < IgxPrefixDirective > ;
266270
@@ -321,9 +325,8 @@ export abstract class PickerBaseDirective implements IToggleView, EditorProvider
321325
322326 /** @hidden @internal */
323327 public ngAfterViewInit ( ) : void {
324- this . subToIconsClicked ( this . toggleComponents , ( ) => this . open ( ) ) ;
325- this . toggleComponents . changes . pipe ( takeUntil ( this . _destroy$ ) )
326- . subscribe ( ( ) => this . subToIconsClicked ( this . toggleComponents , ( ) => this . open ( ) ) ) ;
328+ this . subToIconsClicked ( this . toggleComponents , ( ) => this . toggle ( ) ) ;
329+ this . subToIconsClicked ( this . clearComponents , ( ) => this . clear ( ) ) ;
327330 }
328331
329332 /** @hidden @internal */
@@ -344,17 +347,28 @@ export abstract class PickerBaseDirective implements IToggleView, EditorProvider
344347 }
345348
346349 /** Subscribes to the click events of toggle/clear icons in a query */
347- protected subToIconsClicked ( components : QueryList < IgxPickerToggleComponent > , next : ( ) => any ) : void {
348- components . forEach ( toggle => {
349- toggle . clicked
350- . pipe ( takeUntil ( merge ( components . changes , this . _destroy$ ) ) )
351- . subscribe ( next ) ;
352- } ) ;
350+ private subToIconsClicked (
351+ components : QueryList < IgxPickerToggleComponent | IgxPickerClearComponent > ,
352+ handler : ( ) => void
353+ ) : void {
354+ const subscribeToClick = componentList => {
355+ componentList . forEach ( component => {
356+ component . clicked
357+ . pipe ( takeUntil ( merge ( componentList . changes , this . _destroy$ ) ) )
358+ . subscribe ( handler ) ;
359+ } ) ;
360+ } ;
361+
362+ subscribeToClick ( components ) ;
363+
364+ components . changes . pipe ( takeUntil ( this . _destroy$ ) )
365+ . subscribe ( ( ) => subscribeToClick ( components ) ) ;
353366 }
354367
355368 public abstract select ( value : Date | DateRange | string ) : void ;
356369 public abstract open ( settings ?: OverlaySettings ) : void ;
357370 public abstract toggle ( settings ?: OverlaySettings ) : void ;
358371 public abstract close ( ) : void ;
372+ public abstract clear ( ) : void ;
359373 public abstract getEditElement ( ) : HTMLInputElement ;
360374}
0 commit comments