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

use ignoreActiveValue flag to avoid eating up characters

ulferts7c31cb0eafe8
diff --git a/app/forms/work_packages/progress_form.rb b/app/forms/work_packages/progress_form.rb
index 9f06bd733f3..baf36ce3d0e 100644
--- a/app/forms/work_packages/progress_form.rb
+++ b/app/forms/work_packages/progress_form.rb
@@ -168,22 +168,12 @@ class WorkPackages::ProgressForm < ApplicationForm
end
def default_field_options(name)
- data = {
- "work-packages--progress--preview-progress-target": "progressInput",
- "work-packages--progress--touched-field-marker-target": "progressInput",
- "application-target": "dynamic",
- controller: "turbo-permanent",
- action: "input->work-packages--progress--touched-field-marker#markFieldAsTouched " \
- "focus->turbo-permanent#set " \
- "blur->turbo-permanent#remove"
- }
+ data = { "work-packages--progress--preview-progress-target": "progressInput",
+ "work-packages--progress--touched-field-marker-target": "progressInput",
+ action: "input->work-packages--progress--touched-field-marker#markFieldAsTouched" }
if @focused_field == name
data[:"work-packages--progress--focus-field-target"] = "fieldToFocus"
- # Prevent changes being morphed into the input that is currently focused.
- # After this initial rendering, the turbo-permanent.controller takes over maintaining
- # the attribute on the input currently focused.
- data["turbo-permanent"] = true
end
{ data: }
end
diff --git a/frontend/src/stimulus/controllers/dynamic/turbo-permanent.controller.ts b/frontend/src/stimulus/controllers/dynamic/turbo-permanent.controller.ts
deleted file mode 100644
index 4b2129c7e02..00000000000
--- a/frontend/src/stimulus/controllers/dynamic/turbo-permanent.controller.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * -- copyright
- * OpenProject is an open source project management software.
- * Copyright (C) 2024 the OpenProject GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 3.
- *
- * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
- * Copyright (C) 2006-2013 Jean-Philippe Lang
- * Copyright (C) 2010-2013 the ChiliProject Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * See COPYRIGHT and LICENSE files for more details.
- * ++
- */
-
-import { Controller } from '@hotwired/stimulus';
-
-export default class TurboPermanentController extends Controller {
- set(event:Event) {
- this.toggle(event, true);
- }
-
- remove(event:Event) {
- this.toggle(event, false);
- }
-
- private toggle(event:Event, force:boolean) {
- if (event.target) {
- (event.target as HTMLElement).toggleAttribute('data-turbo-permanent', force);
- }
- }
-}
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/progress/preview-progress.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/progress/preview-progress.controller.ts
index 3ab71313ac9..b2626935b89 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/progress/preview-progress.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/progress/preview-progress.controller.ts
@@ -55,16 +55,9 @@ export default class PreviewProgressController extends Controller {
// See https://github.com/hotwired/turbo/issues/1161 . Once the issue is solved, we can remove
// this code and just use <turbo-frame refresh="morph"> instead.
this.frameMorphRenderer = (event:CustomEvent<TurboBeforeFrameRenderEventDetail>) => {
- event.detail.render = (currentElement:HTMLElement, newElement:HTMLElement) => {
- Idiomorph.morph(currentElement, newElement, {
- morphStyle: 'innerHTML',
- callbacks: {
- beforeNodeMorphed: (oldNode:HTMLElement) => {
- return !oldNode.hasAttribute('data-turbo-permanent');
- },
- },
- });
- };
+ event.detail.render = (currentElement:HTMLElement, newElement:HTMLElement) => {
+ Idiomorph.morph(currentElement, newElement, { ignoreActiveValue: true });
+ };
};
this.progressInputTargets.forEach((target) => {
@@ -76,9 +69,7 @@ export default class PreviewProgressController extends Controller {
}
disconnect() {
- this.progressInputTargets.forEach((target) => {
- target.removeEventListener('input', this.debouncedPreview);
- });
+ this.progressInputTargets.forEach((target) => target.removeEventListener('input', this.debouncedPreview));
const turboFrame = this.formTarget.closest('turbo-frame') as HTMLFrameElement;
turboFrame.removeEventListener('turbo:before-frame-render', this.frameMorphRenderer);
}