From d95a6479d824d507cadb0e7a09d814d21b09f319 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 19 Jun 2023 16:12:13 -0400 Subject: fix: clicking save image does not focus image --- demo.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'demo.js') diff --git a/demo.js b/demo.js index 9b843cc..7050c7c 100644 --- a/demo.js +++ b/demo.js @@ -43,7 +43,8 @@ function download() { // URL.revokeObjectURL(link.href); } -function downloadImage(index) { +function downloadImage(event, index) { + event.stopPropagation(); // so that clicking does not trigger focusImage as well const imageNodes = document.getElementsByClassName('image-preview'); const image = imageNodes[index]; const link = document.createElement('a'); @@ -119,7 +120,7 @@ function renderImages() { const downloadButton = document.createElement('button'); downloadButton.innerText = 'Save Image'; - downloadButton.setAttribute('onclick', `downloadImage(${i})`); + downloadButton.setAttribute('onclick', `downloadImage(event,${i})`); x.className = 'image-preview'; -- cgit v1.2.3