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

Do not replace the active input field's value from the server response to avoid flickering of the input.

Dombi Attilae8b09641b6c4
diff --git a/frontend/src/stimulus/controllers/dynamic/overview/project-life-cycles-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/overview/project-life-cycles-form.controller.ts
index 765fd62cf63..c8418f52b87 100644
--- a/frontend/src/stimulus/controllers/dynamic/overview/project-life-cycles-form.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/overview/project-life-cycles-form.controller.ts
@@ -39,6 +39,7 @@ export default class ProjectLifeCyclesFormController extends FormPreviewControll
private timezoneService:TimezoneService;
private handleFlatpickrDatesChangedBound = this.handleFlatpickrDatesChanged.bind(this);
private updateFlatpickrCalendarBound = this.updateFlatpickrCalendar.bind(this);
+ private preventValueMorphingActiveElementBound = this.preventValueMorphingActiveElement.bind(this);
private previewForm:DebouncedFunc<() => void>;
static targets = ['startDate', 'finishDate', 'duration'];
@@ -59,6 +60,7 @@ export default class ProjectLifeCyclesFormController extends FormPreviewControll
document.addEventListener('date-picker:flatpickr-dates-changed', this.handleFlatpickrDatesChangedBound);
document.addEventListener('turbo:before-stream-render', this.updateFlatpickrCalendarBound);
+ document.addEventListener('turbo:before-morph-attribute', this.preventValueMorphingActiveElementBound);
const activeElement = document.activeElement as HTMLInputElement;
if (activeElement && this.enabledDateInputFields.includes(activeElement)) {
@@ -69,6 +71,8 @@ export default class ProjectLifeCyclesFormController extends FormPreviewControll
disconnect() {
document.removeEventListener('date-picker:flatpickr-dates-changed', this.handleFlatpickrDatesChangedBound);
document.removeEventListener('turbo:before-stream-render', this.updateFlatpickrCalendarBound);
+ document.removeEventListener('turbo:before-morph-attribute', this.preventValueMorphingActiveElementBound);
+ this.previewForm.cancel();
}
onHighlightField(e:Event) {
@@ -122,6 +126,13 @@ export default class ProjectLifeCyclesFormController extends FormPreviewControll
this.previewForm();
}
+ preventValueMorphingActiveElement(event:CustomEvent<{ attributeName:string }>) {
+ const target = event.target as HTMLInputElement;
+ if (target?.id === document.activeElement?.id && event.detail.attributeName === 'value') {
+ event.preventDefault();
+ }
+ }
+
private get dateInputFieldsToUpdate():HTMLInputElement[] {
if (this.highlightedField) {
return [this.highlightedField];