Skip to content

Commit dec4ce6

Browse files
committed
fix(helper): add a bound check to recipe modal click handler
1 parent 977f5c9 commit dec4ce6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

userscripts/natasquare/helper/index.user.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,15 @@ function initRecipeLookup({ v_container, v_sidebar }) {
786786

787787
let hidden = false;
788788
modal.addEventListener("mousedown", function(e) {
789-
if (e.target === e.currentTarget) return closeRecipeModal();
789+
if (e.target === e.currentTarget) {
790+
// apparently this is also true when clicking on the scrollbar
791+
// so a bound check is ineviatable
792+
const rect = modal.getBoundingClientRect();
793+
if (e.clientX < rect.left ||
794+
e.clientX > rect.right ||
795+
e.clientY < rect.top ||
796+
e.clientY > rect.bottom) closeRecipeModal()
797+
}
790798
if (e.button === 2) return;
791799
const item = traverseUntil(e.target, ".item");
792800
if (!item) return;

0 commit comments

Comments
 (0)