summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/flash.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/flash.js')
-rw-r--r--app/assets/javascripts/flash.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/assets/javascripts/flash.js b/app/assets/javascripts/flash.js
index 2bec39ff4d8..7a79f8f5bfc 100644
--- a/app/assets/javascripts/flash.js
+++ b/app/assets/javascripts/flash.js
@@ -9,6 +9,10 @@ const FLASH_TYPES = {
WARNING: 'warning',
};
+const getCloseEl = (flashEl) => {
+ return flashEl.querySelector('.js-close-icon');
+};
+
const hideFlash = (flashEl, fadeTransition = true) => {
if (fadeTransition) {
Object.assign(flashEl.style, {
@@ -56,9 +60,7 @@ const createFlashEl = (message, type) => `
`;
const removeFlashClickListener = (flashEl, fadeTransition) => {
- flashEl
- .querySelector('.js-close-icon')
- .addEventListener('click', () => hideFlash(flashEl, fadeTransition));
+ getCloseEl(flashEl).addEventListener('click', () => hideFlash(flashEl, fadeTransition));
};
/*
@@ -114,6 +116,10 @@ const createFlash = function createFlash({
if (captureError && error) Sentry.captureException(error);
+ flashContainer.close = () => {
+ getCloseEl(flashEl).click();
+ };
+
return flashContainer;
};