Skip to content

Close floating dropdowns when clicking outside them - #911

Merged
wu-sheng merged 1 commit into
masterfrom
fix/dropdown-outside-click
Aug 31, 2026
Merged

Close floating dropdowns when clicking outside them#911
wu-sheng merged 1 commit into
masterfrom
fix/dropdown-outside-click

Conversation

@wu-sheng

Copy link
Copy Markdown
Member

The docs versions picker stayed open after you clicked elsewhere on the page — the only way to dismiss it was to find its summary again and click that.

The cause is plain <details> behaviour: a native <details> stays open until its own summary is toggled, and nothing on the site was closing it. The same pattern is used by two other dropdowns, so all three had the bug:

dropdown where
details.docs-ver docs landing — the reported one
details.dl-more downloads cards, the "+N more" version list
details.topic-filter blog list (EN and 中文)

Behaviour now

  • Clicking anywhere outside closes the open panel.
  • Escape closes it too.
  • Opening one closes the others, so only a single panel is ever up.
  • Clicking inside an open panel leaves it open, so the version links stay reachable.

details.dl-archived is deliberately not included — it is an inline accordion on the downloads page rather than a floating panel, and should stay where the reader put it.

Where it is wired

A new layouts/partials/hooks/body-end.html, overriding the theme's hook of the same name. That hook is called from the theme's scripts.html, which every one of our baseof templates already loads — so one file covers docs, downloads, blog and zh, and the theme stays unforked. It is the same approach hooks/head-end.html uses to carry the SEO partials.

The theme's own body-end.html holds nothing but an Algolia docsearch placeholder, which is kept verbatim in the override so nothing is lost.

Verification

Driven in a real browser against a local build, not just read:

1. open first via summary        -> open=true
2. click elsewhere on the page   -> open=false   (was the bug)
3. open a second one             -> first=false second=true
4. Escape                        -> first=false second=false
5. click inside the open panel   -> open=true    (must stay open)

Repeated across all three dropdown kinds, and confirmed .dl-archived still stays open after an outside click:

downloads .dl-more                 opened=true  after outside click=false
downloads .dl-archived (accordion) opened=true  after outside click=true
blog .topic-filter                 opened=true  after outside click=false

Also confirmed the script is emitted exactly once on each of /docs/, /downloads/, /blog/ and /zh/.

A native <details> stays open until its own summary is clicked again, so the
docs "versions" picker — and the downloads "+N more" and blog topic filter,
which share the pattern — hung over the page after the reader moved on. The
only way to dismiss one was to find its summary again.

Close them on an outside click and on Escape, and let opening one close the
others so only a single panel is ever up. Clicking inside an open panel keeps
it open, so the version links stay reachable.

Scoped by class to the three floating dropdowns. .dl-archived is deliberately
excluded: it is an inline accordion rather than a floating panel, and should
stay where the reader put it.

Wired through a new layouts/partials/hooks/body-end.html, which overrides the
theme's own hook — called from its scripts.html, which every one of our baseof
templates already loads. That covers docs, downloads, blog and zh from one
file and leaves the theme unforked, the same way hooks/head-end.html carries
the SEO partials. The theme's body-end only holds an Algolia docsearch
placeholder, kept verbatim so the override loses nothing.

Verified by driving a real browser against a local build: opening works,
an outside click closes, opening a second closes the first, Escape closes
all, and a click inside the panel leaves it open. Confirmed on all three
dropdown kinds, and confirmed .dl-archived still stays open.
@netlify

netlify Bot commented Aug 31, 2026

Copy link
Copy Markdown

Deploy Preview for skywalking-website-preview ready!

Name Link
🔨 Latest commit cc0aac8
🔍 Latest deploy log https://app.netlify.com/projects/skywalking-website-preview/deploys/6a94c4450bda800008b2092d
😎 Deploy Preview https://deploy-preview-911--skywalking-website-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@wu-sheng
wu-sheng merged commit 36d23dc into master Aug 31, 2026
4 of 5 checks passed
@wu-sheng
wu-sheng deleted the fix/dropdown-outside-click branch August 31, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant