@@ -372,34 +372,40 @@ export class KbqTagList
372
372
} ) ;
373
373
374
374
// When the list changes, re-subscribe
375
- this . tags . changes . pipe ( startWith ( null ) , takeUntilDestroyed ( this . destroyRef ) ) . subscribe ( ( ) => {
376
- if ( this . disabled ) {
377
- // Since this happens after the content has been
378
- // checked, we need to defer it to the next tick.
379
- Promise . resolve ( ) . then ( ( ) => {
380
- this . syncTagsDisabledState ( ) ;
381
- } ) ;
382
- }
375
+ this . tags . changes
376
+ . pipe ( startWith ( null ) , takeUntilDestroyed ( this . destroyRef ) )
377
+ . subscribe ( ( currentTags : QueryList < KbqTag > | null ) => {
378
+ if ( this . disabled ) {
379
+ // Since this happens after the content has been
380
+ // checked, we need to defer it to the next tick.
381
+ Promise . resolve ( ) . then ( ( ) => {
382
+ this . syncTagsDisabledState ( ) ;
383
+ } ) ;
384
+ }
383
385
384
- this . resetTags ( ) ;
386
+ this . resetTags ( ) ;
385
387
386
- // Reset tags selected/deselected status
387
- this . initializeSelection ( ) ;
388
+ // Reset tags selected/deselected status
389
+ this . initializeSelection ( ) ;
388
390
389
- // Check to see if we need to update our tab index
390
- this . updateTabIndex ( ) ;
391
+ // Check to see if we need to update our tab index
392
+ this . updateTabIndex ( ) ;
391
393
392
- // Check to see if we have a destroyed tag and need to refocus
393
- this . updateFocusForDestroyedTags ( ) ;
394
+ // Check to see if we have a destroyed tag and need to refocus
395
+ this . updateFocusForDestroyedTags ( ) ;
394
396
395
- // Defer setting the value in order to avoid the "Expression
396
- // has changed after it was checked" errors from Angular.
397
- Promise . resolve ( ) . then ( ( ) => {
398
- this . tagChanges . emit ( this . tags . toArray ( ) ) ;
399
- this . stateChanges . next ( ) ;
400
- this . propagateTagsChanges ( ) ;
397
+ // Defer setting the value in order to avoid the "Expression
398
+ // has changed after it was checked" errors from Angular.
399
+ Promise . resolve ( ) . then ( ( ) => {
400
+ this . tagChanges . emit ( this . tags . toArray ( ) ) ;
401
+ this . stateChanges . next ( ) ;
402
+
403
+ // do not call on initial
404
+ if ( currentTags ) {
405
+ this . propagateTagsChanges ( ) ;
406
+ }
407
+ } ) ;
401
408
} ) ;
402
- } ) ;
403
409
404
410
this . propagateSelectableToChildren ( ) ;
405
411
}
@@ -445,7 +451,7 @@ export class KbqTagList
445
451
registerInput ( inputElement : KbqTagTextControl ) : void {
446
452
this . tagInput = inputElement ;
447
453
448
- // todo need rethink about it
454
+ // todo need rethink about it (#DS-3740)
449
455
if ( this . ngControl && inputElement . ngControl ?. statusChanges ) {
450
456
inputElement . ngControl . statusChanges . subscribe ( ( ) =>
451
457
this . ngControl . control ! . setErrors ( inputElement . ngControl ! . errors )
@@ -495,7 +501,7 @@ export class KbqTagList
495
501
return ;
496
502
}
497
503
498
- // TODO: ARIA says this should focus the first `selected` tag if any are selected.
504
+ // TODO: ARIA says this should focus the first `selected` tag if any are selected. (#DS-3740)
499
505
// Focus on first element if there's no tagInput inside tag-list
500
506
if ( this . tagInput && this . tagInput . focused ) {
501
507
// do nothing
@@ -542,6 +548,7 @@ export class KbqTagList
542
548
543
549
setSelectionByValue ( value : any , isUserInput : boolean = true ) {
544
550
this . clearSelection ( ) ;
551
+ // @TODO seems like redundant action, need to double check (#DS-3740)
545
552
this . tags . forEach ( ( tag ) => tag . deselect ( ) ) ;
546
553
547
554
if ( Array . isArray ( value ) ) {
@@ -704,7 +711,7 @@ export class KbqTagList
704
711
}
705
712
706
713
/** Emits change event to set the model value. */
707
- // todo need rethink this method and selection logic
714
+ // todo need rethink this method and selection logic (#DS-3740)
708
715
private propagateChanges ( fallbackValue ?: any ) : void {
709
716
let valueToEmit : any ;
710
717
0 commit comments