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

remove container of flash message after it is closed, so that it doesn't become visible with next flash message

Ivan Kuchin1316b43b06a6
diff --git a/app/components/op_primer/flash_component.rb b/app/components/op_primer/flash_component.rb
index fed84bf511f..15a445c0331 100644
--- a/app/components/op_primer/flash_component.rb
+++ b/app/components/op_primer/flash_component.rb
@@ -38,6 +38,8 @@ module OpPrimer
system_arguments[:test_selector] ||= "op-primer-flash-message"
system_arguments[:dismiss_scheme] ||= :remove
system_arguments[:dismiss_label] ||= I18n.t(:button_close)
+ system_arguments[:data] ||= {}
+ system_arguments[:data]["flash-target"] = "flash"
@autohide = system_arguments[:scheme] == :success && system_arguments[:dismiss_scheme] != :none
diff --git a/frontend/src/stimulus/controllers/flash.controller.ts b/frontend/src/stimulus/controllers/flash.controller.ts
index d09aad6d196..f97ad77f4d3 100644
--- a/frontend/src/stimulus/controllers/flash.controller.ts
+++ b/frontend/src/stimulus/controllers/flash.controller.ts
@@ -11,9 +11,10 @@ export default class FlashController extends ApplicationController {
static targets = [
'item',
+ 'flash', // only to detect removal
];
- declare readonly itemTargets:HTMLElement;
+ declare readonly itemTargets:HTMLElement[];
reloadPage() {
window.location.reload();
@@ -25,4 +26,12 @@ export default class FlashController extends ApplicationController {
setTimeout(() => element.remove(), SUCCESS_AUTOHIDE_TIMEOUT);
}
}
+
+ flashTargetDisconnected() {
+ this.itemTargets.forEach((target:HTMLElement) => {
+ if (target.innerHTML === '') {
+ target.remove();
+ }
+ });
+ }
}