lucca-front icon indicating copy to clipboard operation
lucca-front copied to clipboard

fix(number-format-input): formControl incompatibility

Open guillerot opened this issue 4 months ago • 3 comments

Description

Issue :

        <lu-number-format-input
          required
          placeholder="Placeholder"
          formatStyle="currency"
          [useAutoPrefixSuffix]="true"
          [currency]="costsForm.controls.currency.value?.id"
          currencyDisplay="name"
          [formControl]="testFC"
        >
        </lu-number-format-input>

admin-training.store.ts:460 ERROR TypeError: Cannot read properties of null (reading 'pipe')
    at new _NumberFormatInputComponent (lucca-front-ng-forms.mjs:618:68)
    at NodeInjectorFactory.NumberFormatInputComponent_Factory [as factory] (lucca-front-ng-forms.mjs:668:14)
    at getNodeInjectable (core.mjs:5872:38)
    at instantiateAllDirectives (core.mjs:12400:23)
    at createDirectivesInstances (core.mjs:11822:3)
    at ɵɵelementStart (core.mjs:23526:5)
    at ɵɵelement (core.mjs:23583:3)
    at CostsFormComponent2_Template (template.html:53:9)
    at executeTemplate (core.mjs:11788:5)
    at renderView (core.mjs:12950:7)

Caused by ngControl.valueChanges not available when converting to signal

#suffixPrefixValue = toSignal(this.ngControl.valueChanges.pipe(startWith(1)));

value should be access after view init

ngAfterViewInit(): void {
  this.ngControl?.valueChanges
    ?.pipe(takeUntilDestroyed(this.#destroyRef), startWith(this.ngControl.value))
    .subscribe((value) => this.#suffixPrefixValue.set(value as number));
}


guillerot avatar Oct 04 '24 16:10 guillerot