fix: mark input as dirty after patching value
This commit is contained in:
@@ -12,4 +12,4 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<app-bar-code-reader [scan]="scan()" (result)="control.patchValue($event.detail?.code?.rawValue ?? '')"></app-bar-code-reader>
|
<app-bar-code-reader [scan]="scan()" (result)="updateBarcode($event)"></app-bar-code-reader>
|
||||||
@@ -7,6 +7,7 @@ import { BarCodeReaderWrapper } from '../bar-code-reader/bar-code-reader';
|
|||||||
import { ControlValueAccessor, FormControl, NgControl, ReactiveFormsModule } from '@angular/forms';
|
import { ControlValueAccessor, FormControl, NgControl, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { UpperfirstPipe } from '../../pipes/upperfirst-pipe';
|
import { UpperfirstPipe } from '../../pipes/upperfirst-pipe';
|
||||||
import { TranslatePipe } from '@ngx-translate/core';
|
import { TranslatePipe } from '@ngx-translate/core';
|
||||||
|
import { DetectedBarcode } from '../../types/globalThis';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-bar-code-input',
|
selector: 'app-bar-code-input',
|
||||||
@@ -38,6 +39,19 @@ export class BarCodeInput implements ControlValueAccessor, OnInit {
|
|||||||
this.control = <FormControl>this.controlDir?.control;
|
this.control = <FormControl>this.controlDir?.control;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateBarcode(
|
||||||
|
barcodeEvent: Event & {
|
||||||
|
detail?: {
|
||||||
|
code: DetectedBarcode | null;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
let code = barcodeEvent.detail?.code?.rawValue
|
||||||
|
if(code) {
|
||||||
|
this.control.patchValue(code);
|
||||||
|
this.control.markAsDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
writeValue(obj: any): void {}
|
writeValue(obj: any): void {}
|
||||||
registerOnChange(fn: any): void {}
|
registerOnChange(fn: any): void {}
|
||||||
registerOnTouched(fn: any): void {}
|
registerOnTouched(fn: any): void {}
|
||||||
|
|||||||
Reference in New Issue
Block a user