It seems pretty straightforward to me.
Uncloaking a post will save its height at that time. If you’ve expanded details, the height will have changed. When you uncloak it, it uses the previously stored height, which is now incorrect.
I think to solve this the details plugin will have to remember what was expanded, and when re-rendering that post re-apply the opened state.
Otherwise it feels weird - why is discourse collapsing details just because a post scrolled out of view?