[details] breaks when embedded in a paragraph

AI 生成的摘要

In Discourse 1.8.0.beta13, the [details] tag fails to hide content when embedded within a paragraph, though it works when separated by newlines. This inconsistency is reproducible across browsers and stems from HTML generation. While codinghorror notes that [details] is intended as a block-level element and suggests using [spoiler] for inline use, okeefe and jomaxro argue that the preview misleadingly shows the expected behavior — hiding content — while the final rendered post does not, causing confusion for users. zogstrip acknowledges the inconsistency as a bug and confirms a fix: preview and cooked post now behave identically — neither supports [details] embedded in paragraphs. okeefe emphasizes the real-world impact: users unknowingly post unhidden spoilers, leading to frustration. The core issue is not just technical but UX-related — the mismatch between preview and final output undermines user trust. The fix aligns both states to reject inline [details], reinforcing the need to use [spoiler] for inline spoiler content.

In Discourse 1.8.0.beta13, the [details=Spoiler]This should be hidden[details] logic doesn’t work if it’s embedded in a paragraph. It does work if it’s separated by a newline. The problem appears to be in the generated html, as it’s reproducible in Chrome, Firefox, and Safari.


details tag with proceeding newline

This text is hidden until you click the text.


Here’s an embedded [details=details tag embedded]This text shows up all the time in the page, but the preview makes it looks like it works.[/details] paragraph.

Not really a bug, we expect newlines there.

Expecting newlines might be the bug.

Why does the preview have the expected behavior, then? One would expect that and the rendered version to act the same.

Using [details] for spoilers and not knowing this buggy behavior means you think you left a properly hidden spoiler when in fact you didn’t. This has been super aggravating, confusing, and unexpected for myself and friends on another discourse instance.

Details is by definition a block level element. If you want inline, use the other style which is called .. wait for it.. SPOILER.

It works kinda like this you see.

It works [spoiler]kinda like this[/spoiler] you see.

I think this is a real bug here. The [details] tag renders differently in preview than in the cooked post. I’ve experienced it myself. I’ve also had to try and explain to my users why something looks OK in preview but fails once posted.

3 个赞

Yeah, the preview not being consistent with the final cooked post is annoying. Will fix.

4 个赞

Preview is now consistent with the cooked post (none of them support being “embedded” in a paragraph).

2 个赞