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.