Skip to content

Commit

Permalink
Merge pull request #17495 from opf/remove-closed-flash-container
Browse files Browse the repository at this point in the history
Remove closed banner container
  • Loading branch information
oliverguenther authored Dec 18, 2024
2 parents a8fc3ad + 1316b43 commit 07f560a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/components/op_primer/flash_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def initialize(**system_arguments)
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

Expand Down
11 changes: 10 additions & 1 deletion frontend/src/stimulus/controllers/flash.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
});
}
}

0 comments on commit 07f560a

Please sign in to comment.