diff --git a/src/js/exersises.js b/src/js/exersises.js index b83fade..c362d4f 100644 --- a/src/js/exersises.js +++ b/src/js/exersises.js @@ -616,22 +616,16 @@ function dataToStorage(data) { const modalBackDrop = document.querySelector('.pop-backdrop.is-open'); - async function closeWithBackDrop(event) { - if ( - event.target.classList.contains('pop-ex-close-btn') || - event.key === 'Escape' - ) { - await popUp(data); - modal.innerHTML = ''; - modalBackDrop.classList.remove('is-open'); - } + async function closeWithBackDrop() { + await popUp(data); + modal.innerHTML = ''; + modalBackDrop.classList.remove('is-open'); } if (modalBackDrop) { modalBackDrop.addEventListener('click', closeWithBackDrop); - - document.addEventListener('keydown', closeWithBackDrop); } + window.addEventListener('keydown', function (e) { if (e.key === 'Escape') { modal.innerHTML = ''; @@ -643,7 +637,6 @@ function dataToStorage(data) { } const exPopClose = document.querySelector('.pop-ex-close-btn'); - if (exPopClose) { exPopClose.addEventListener('click', closeHandler); } else {