diff options
author | Bryce Russell | 2023-05-24 04:48:28 -0500 |
---|---|---|
committer | GitHub | 2023-05-24 11:48:28 +0200 |
commit | c86c1d6e93d978d13e42bbc449e0225a06793ba3 (patch) | |
tree | 34eca3ecd4d916338668c30ae5df45b271866519 | |
parent | 1d2412fccafd284e127ae72882f344ea5a11d21b (diff) | |
download | IT.starlight-c86c1d6e93d978d13e42bbc449e0225a06793ba3.tar.gz IT.starlight-c86c1d6e93d978d13e42bbc449e0225a06793ba3.tar.bz2 IT.starlight-c86c1d6e93d978d13e42bbc449e0225a06793ba3.zip |
Improve outside click detection on search modal (#85)
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
-rw-r--r-- | .changeset/silver-icons-reflect.md | 5 | ||||
-rw-r--r-- | packages/starlight/components/Search.astro | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/silver-icons-reflect.md b/.changeset/silver-icons-reflect.md new file mode 100644 index 00000000..ceb94602 --- /dev/null +++ b/.changeset/silver-icons-reflect.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Improve outside click detection on the search modal diff --git a/packages/starlight/components/Search.astro b/packages/starlight/components/Search.astro index a9c0ef73..6e58b46d 100644 --- a/packages/starlight/components/Search.astro +++ b/packages/starlight/components/Search.astro @@ -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) => { |