From 8d2da794715a3b36e4b48331ed24660358a292ae Mon Sep 17 00:00:00 2001 From: Daniil888-m Date: Wed, 11 Dec 2024 23:48:18 +0300 Subject: [PATCH] added preventDefault --- js/big-picture-popup.js | 3 ++- js/main.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/js/big-picture-popup.js b/js/big-picture-popup.js index 4a7ecbf..c73149e 100644 --- a/js/big-picture-popup.js +++ b/js/big-picture-popup.js @@ -37,7 +37,8 @@ function renderComments(photoId) { return commentFragmentList; } -function hidePhotoPopup() { +function hidePhotoPopup(e) { + e.preventDefault(); hide(bigPhotoPopup); document.removeEventListener('keydown', onEscapeKeydown); document.body.classList.remove('modal-open'); diff --git a/js/main.js b/js/main.js index e4a7d92..859be33 100644 --- a/js/main.js +++ b/js/main.js @@ -7,6 +7,7 @@ document.addEventListener('click', (e) => { const currentPicture = e.target.closest('.picture'); if (currentPicture) { + e.preventDefault(); openBigPhotoPopup(currentPicture.dataset.photoId); } });