@wizishop/angular-components 14.4.32 → 14.4.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -524,20 +524,16 @@ class ValueChangeService {
524
524
  }
525
525
  handleInitialSelectedOption() {
526
526
  setTimeout(() => {
527
- this.findInitialSelectedOption();
527
+ const selectedOption = this.getSelectedOptionComponent();
528
+ if (selectedOption && this.value !== selectedOption.value) { // avoid to emit event when there is an initial value (e.g. from ngModel)
529
+ this.value = selectedOption.value;
530
+ }
528
531
  if (this.disabled) {
529
532
  this.optionChildren.forEach((option) => option.setDisabledState(true));
530
533
  }
531
534
  this.handleValueChange();
532
535
  }, 0);
533
536
  }
534
- findInitialSelectedOption() {
535
- const selectedOption = this.getSelectedOptionComponent();
536
- if (!selectedOption) {
537
- return;
538
- }
539
- this.value = selectedOption.value;
540
- }
541
537
  handleSelectedOptionsEvent() {
542
538
  this.optionSelectedChangeListeners().subscribe((value) => {
543
539
  this.value = value;
@@ -556,13 +552,13 @@ class ValueChangeService {
556
552
  }
557
553
  optionSelectedChangeListeners() {
558
554
  const selectedChange$ = this.optionChildren.map((option) => {
559
- return option.selectedChange.pipe(filter(() => !this.disabled), map((selected) => option.getValue()));
555
+ return option.selectedChange.pipe(filter(() => !this.disabled), map(() => option.getValue()));
560
556
  });
561
557
  return merge(...selectedChange$).pipe(takeUntil(this.resetListeners$));
562
558
  }
563
559
  changeSelectedOption() {
564
560
  this.optionChildren.forEach((optionComponent, index) => {
565
- optionComponent.setSelected(typeof this.value === undefined ? false : optionComponent.value === this.value);
561
+ optionComponent.setSelected(optionComponent.value === this.value);
566
562
  if (optionComponent.selected) {
567
563
  this.indexSelectedOption = index;
568
564
  }
@@ -590,7 +586,6 @@ class SelectDirective {
590
586
  this.onChange = () => { };
591
587
  this.onTouch = () => { };
592
588
  }
593
- // TODO add default value in wacSelect/wacOption
594
589
  get tabindex() {
595
590
  return this.tabIndex;
596
591
  }