Skip to content

Commit 4476813

Browse files
GrabowskiMjuskora
authored andcommitted
moved listener to helper
1 parent 5130462 commit 4476813

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/bundle/Resources/public/js/scripts/helpers/modal.helper.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ const controlManyZIndexes = (items, listenerContainer) => {
5050
};
5151
};
5252

53+
const forceHideLoaderOnHideEvent = (event) => {
54+
if (event.target.classList.contains('ibexa-modal--with-blurred-loader')) {
55+
hideModalLoader({ modalNode: event.target });
56+
}
57+
};
58+
5359
const showModalLoader = ({ headerText, descriptionText, modalNode }) => {
5460
if (!modalNode) {
5561
return;
@@ -80,6 +86,8 @@ const showModalLoader = ({ headerText, descriptionText, modalNode }) => {
8086
}
8187

8288
modalNode.classList.add('ibexa-modal--with-blurred-loader');
89+
90+
document.body.addEventListener('hidden.bs.modal', forceHideLoaderOnHideEvent);
8391
};
8492

8593
const hideModalLoader = ({ modalNode }) => {
@@ -94,12 +102,8 @@ const hideModalLoader = ({ modalNode }) => {
94102
descriptionTextNode.innerText = '';
95103

96104
modalNode.classList.remove('ibexa-modal--with-blurred-loader');
97-
};
98105

99-
document.body.addEventListener('hidden.bs.modal', (event) => {
100-
if (event.target.classList.contains('ibexa-modal--with-blurred-loader')) {
101-
hideModalLoader({ modalNode: event.target });
102-
}
103-
});
106+
document.body.removeEventListener('hidden.bs.modal', forceHideLoaderOnHideEvent);
107+
};
104108

105109
export { controlZIndex, controlManyZIndexes, showModalLoader, hideModalLoader };

0 commit comments

Comments
 (0)