Skip to content

[3.0] Reveal an inline spoiler when it is clicked - #9495

Merged
jdarwood007 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/spoiler-toggle
Aug 11, 2026
Merged

[3.0] Reveal an inline spoiler when it is clicked#9495
jdarwood007 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/spoiler-toggle

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Clicking an inline spoiler does nothing. The content stays hidden.

The tag renders as a span whose content is hidden in the stylesheet, and only a revealed class brings it back:

.bbc_inline_spoiler > span { visibility: hidden; }
.bbc_inline_spoiler.revealed > span { visibility: visible; }

Nothing adds that class. 588d99d63 ("Remove string evaluations") took out the toggleSpoiler function and both places that attached it, and nothing replaced them — the word revealed no longer appears anywhere outside the minified build artifacts. It looks like collateral damage in a cleanup rather than a deliberate removal; the handler had been added on purpose five months earlier in f82d5e76c.

Only one of the two spoiler forms is affected. Spoiler1::validate() switches to a details element when the content spans several lines or a text parameter is given, and that form is plain HTML that never needed script. A short one-line [spoiler]…[/spoiler] gets the inline span, and that is the broken one — which is probably why this went unreported for a while.

There is an odd side effect worth noting: noscript.css reveals the spoiler on :hover, so it currently behaves better with JavaScript disabled than enabled.

This listens on the document rather than binding each spoiler. The removed code had to attach in two places — once at load and again after a preview — and still missed any post that arrived after the page did, which is most of them: a quoted post, a personal message read in the popup, a preview. Delegation covers all of those with no re-attachment. The span holds a button so that assistive technology and the keyboard have something to press, and closest() answers for the button and the span alike, so both routes toggle the one element the CSS looks at.

Tested against a real DOM (jsdom) using the markup BBCodeParser actually emits: reveals on the button, on the span and on the text; toggles back; leaves the class on the span and not the button; ignores clicks elsewhere; and works on a spoiler inserted after load.

Issues References (Fixes|Related|Closes)

Reported by a user on the community forum. Regression from 588d99d63.

The content of an inline spoiler is hidden in the stylesheet and only a
'revealed' class brings it back, so the tag needs something listening for
the click. That listener went out with 588d99d, which removed the
handler and the two places that attached it, and nothing took its place -
so clicking an inline spoiler has done nothing since.

Listens on the document instead of binding each spoiler. The old code had
to attach in two places and still missed any post that arrived after the
page did, which is most of them: a preview, a quoted post, a personal
message read in the popup. The span holds a button so assistive
technology and the keyboard have something to press, and closest() answers
for the button and the span alike.

Spoilers written across several lines, or given a text parameter, are not
affected - those render as a details element and never needed script.

Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 5 milestone Aug 11, 2026
@jdarwood007
jdarwood007 merged commit 74c56e2 into SimpleMachines:release-3.0 Aug 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants