Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Don't run onChange during writeValue for spot text

Oliver Günther19ea3e18b17d
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
index de947cd6521..402a2d42b81 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
@@ -330,6 +330,7 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
this.dates[key] = mappedDate(val);
const dateValue = parseDate(val || '') || undefined;
this.enforceManualChangesToDatepicker(false, dateValue);
+ this.cdRef.detectChanges();
}
}
diff --git a/frontend/src/app/spot/components/text-field/text-field.component.html b/frontend/src/app/spot/components/text-field/text-field.component.html
index f4f78fb949d..982f06fc115 100644
--- a/frontend/src/app/spot/components/text-field/text-field.component.html
+++ b/frontend/src/app/spot/components/text-field/text-field.component.html
@@ -4,14 +4,15 @@
[attr.name]="name"
[disabled]="disabled"
[placeholder]="placeholder"
- [(ngModel)]="value"
+ [ngModel]="value"
+ (ngModelChange)="valueChanged($event)"
(focus)="onInputFocus($event)"
(blur)="onInputBlur($event)"
#input
/>
<button
*ngIf="showClearButton && value !== '' && !disabled"
- (click)="value = ''"
+ (click)="valueChanged('')"
type="button"
class="spot-text-field--clear-button"
>
diff --git a/frontend/src/app/spot/components/text-field/text-field.component.ts b/frontend/src/app/spot/components/text-field/text-field.component.ts
index b594f5d626a..57393525b20 100644
--- a/frontend/src/app/spot/components/text-field/text-field.component.ts
+++ b/frontend/src/app/spot/components/text-field/text-field.component.ts
@@ -8,8 +8,12 @@ import {
Input,
Output,
EventEmitter,
+ ChangeDetectorRef,
} from '@angular/core';
-import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
+import {
+ ControlValueAccessor,
+ NG_VALUE_ACCESSOR,
+} from '@angular/forms';
@Component({
selector: 'spot-text-field',
@@ -25,7 +29,8 @@ export class SpotTextFieldComponent implements ControlValueAccessor {
@HostBinding('class.spot-text-field_focused') public focused = false;
- @HostListener('click') public onParentClick() {
+ @HostListener('click')
+ public onParentClick() {
this.input.nativeElement.focus();
}
@@ -39,14 +44,10 @@ export class SpotTextFieldComponent implements ControlValueAccessor {
@Input() public placeholder = '';
- @Input('value') public _value = '';
-
- get value():string {
- return this._value;
- }
+ @Input() public value = '';
- set value(value:string) {
- this._value = value;
+ valueChanged(value:string) {
+ this.writeValue(value);
this.onChange(value);
this.onTouched(value);
}
@@ -55,6 +56,10 @@ export class SpotTextFieldComponent implements ControlValueAccessor {
@Output() public inputBlur = new EventEmitter<FocusEvent>();
+ constructor(
+ private cdRef:ChangeDetectorRef,
+ ) {}
+
onInputFocus(event:FocusEvent):void {
this.focused = true;
this.inputFocus.next(event);
@@ -67,6 +72,7 @@ export class SpotTextFieldComponent implements ControlValueAccessor {
writeValue(value:string) {
this.value = value || '';
+ this.cdRef.markForCheck();
}
onChange = (_:string):void => {};