]> git.ardis.lu - ens2hex/commitdiff
Fix double dialog when clicking on upload label
authorArdis Lu <ardisglu@gmail.com>
Mon, 3 Oct 2022 07:21:30 +0000 (00:21 -0700)
committerArdis Lu <ardisglu@gmail.com>
Mon, 3 Oct 2022 07:21:30 +0000 (00:21 -0700)
Clicking an input's label is equal to clicking the input itself. So .stopPropagation() needs to be applied to the label as well as the input.

index.html

index 2d7a4d4c6a2954fdc5777cf62e7baf8ccb338bd8..6f6d469a52e56cb53ae1b6393b5e60aa62a6389f 100644 (file)
     div.addEventListener('drop', e => input.files = e.dataTransfer.files);
     div.addEventListener('click', _ => input.click());
     input.addEventListener('click', e => e.stopPropagation()); // Prevent 'click' from getting propagated to div (or else there will be two dialogs)
+    document.querySelector('label[for="file"]').addEventListener('click', e => e.stopPropagation());
 
     // Implement namehash as defined in https://eips.ethereum.org/EIPS/eip-137
     // Does NOT include the '0x' prefix in the return value so it can be easily passed into JSON-RPC
This page took 0.041806 seconds and 4 git commands to generate.