Skip to content

Commit

Permalink
Improve outside click detection on search modal (#85)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
  • Loading branch information
BryceRussell and delucis committed May 24, 2023
1 parent 1d2412f commit c86c1d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/silver-icons-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/starlight": patch
---

Improve outside click detection on the search modal
2 changes: 1 addition & 1 deletion packages/starlight/components/Search.astro
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const t = useTranslations(Astro.props.locale);

/** Close the modal if a user clicks outside of the modal. */
const onWindowClick = (event: MouseEvent) => {
if (!dialogFrame.contains(event.target as Node)) closeModal();
if (document.body.contains(event.target as Node) && !dialogFrame.contains(event.target as Node)) closeModal();
};

const openModal = (event?: MouseEvent) => {
Expand Down

0 comments on commit c86c1d6

Please sign in to comment.