# 细节标签内的Spoiler不切换

**URL:** <https://meta.discourse.org/t/spoilers-don-t-toggle-when-inside-details/194499>\
**Category:** Bug\
**Tags:** completed, hide-details\
**Created:** [2021年六月21日 01:59 UTC](https://meta.discourse.org/t/spoilers-don-t-toggle-when-inside-details/194499 "2021-06-21T01:59:28Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![tannerabread](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tannerabread/32/526153_2.png) [@tannerabread](https://meta.discourse.org/u/tannerabread)\
**Post date:** [2026年六月29日 17:48 UTC](https://meta.discourse.org/t/spoilers-don-t-toggle-when-inside-details/194499/7 "2026-06-29T17:48:47Z")

</div>

嗨 @Noble_Fish，感谢让这个话题重新活跃起来！我刚刚发布了一个修复 ~~它应该很快就能用~~ 。

> <https://github.com/discourse/discourse/pull/41266>
>
> \`INTERACTIVE\_SELECTOR\` includes "details" so that clicking a \`\<details\>\` inside …a spoiler expands it without also re-blurring the surrounding spoiler. But because \`closest()\` walks up the DOM tree, every click inside a \`\[spoiler\]\` that happens to be nested inside a \`\[details\]\` also matches \`closest("details")\` against the parent \`\<details\>\` — making such a spoiler impossible to re-blur once revealed.
> 
> Fix: scope the \`closest()\` result with \`element.contains(...)\` so only interactive ancestors that live inside the spoiler block re-blurring. Interactive ancestors above the spoiler are ignored.
> 
> Tests cover both directions: a spoiler-inside-details can re-blur, and clicking an interactive descendant of a revealed spoiler still does not re-blur it.
> 
> Context: https://meta.discourse.org/t/spoilers-don-t-toggle-when-inside-details/194499

---

_[View the full topic](https://meta.discourse.org/t/spoilers-don-t-toggle-when-inside-details/194499)._
