Skip to content

Commit a223828

Browse files
committed
add comment, dialog click-handler includes clicks on backdrop
1 parent c58f131 commit a223828

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js

+5
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,17 @@ var setupSearchButtons = () => {
305305

306306
// If user clicks outside the search modal dialog, then close it.
307307
const searchDialog = document.getElementById("pst-search-dialog");
308+
// Dialog click handler includes clicks on dialog ::backdrop.
308309
searchDialog.addEventListener("click", (event) => {
309310
if (!searchDialog.open) {
310311
return;
311312
}
312313

314+
// Dialog.getBoundingClientRect() does not include ::backdrop. (This is the
315+
// trick that allows us to determine if click was inside or outside of the
316+
// dialog: click handler includes backdrop, getBoundingClientRect does not.)
313317
const { left, right, top, bottom } = searchDialog.getBoundingClientRect();
318+
314319
// 0, 0 means top left
315320
const clickWasOutsideDialog =
316321
event.clientX < left ||

0 commit comments

Comments
 (0)