From a22382856ff6c71a250b77435280cab557435857 Mon Sep 17 00:00:00 2001 From: gabalafou Date: Fri, 19 Jul 2024 16:59:40 +0200 Subject: [PATCH] add comment, dialog click-handler includes clicks on backdrop --- .../assets/scripts/pydata-sphinx-theme.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js index 31a125498..48a1e4257 100644 --- a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js +++ b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js @@ -305,12 +305,17 @@ var setupSearchButtons = () => { // If user clicks outside the search modal dialog, then close it. const searchDialog = document.getElementById("pst-search-dialog"); + // Dialog click handler includes clicks on dialog ::backdrop. searchDialog.addEventListener("click", (event) => { if (!searchDialog.open) { return; } + // Dialog.getBoundingClientRect() does not include ::backdrop. (This is the + // trick that allows us to determine if click was inside or outside of the + // dialog: click handler includes backdrop, getBoundingClientRect does not.) const { left, right, top, bottom } = searchDialog.getBoundingClientRect(); + // 0, 0 means top left const clickWasOutsideDialog = event.clientX < left ||