== Steps to reproduce
# Login and visit https://en.wikipedia.org/w/index.php?title=Dog&diff=prev&oldid=1136163079
# Scroll halfway down the page
== Expected results
- The TOC has 30px of space between its top and the top of the viewport
== Actual results
- The TOC has ~93px of space between its top and the top of the viewport
{F36819867}
=== Check any additional observations
[x] Observed on the [[ https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Dog&diff=prev&oldid=550357&diffmode=source | beta cluster wiki ]]
[x] Observed on a [[ https://en.wikipedia.org/w/index.php?title=Dog&diff=prev&oldid=1136163079 | production wiki ]]
[x] Observed on [[ https://en.wikipedia.org/w/index.php?title=Dog&diff=prev&oldid=1136163079 | Vector 2022 desktop skin ]]
[] Observed on [[ https://en.m.wikipedia.org/wiki/Barack_Obama | MinervaNeue responsive skin ]]
[x] Observed while logged in
[] Observed while //not// logged in (anonymous)
== Developer Notes
The cause of this is also the cause of T300612 (which remains unresolved) and will also affect the sticky page tools when logged-in T318169. In each issue, we have JS that [[ https://github.com/wikimedia/mediawiki-skins-Vector/blob/be0476b17fd39218b90dcfcedbe7e5468bc9b16a/resources/skins.vector.es6/stickyHeader.js#L514-L538 | prevents showing the sticky header ]] on certain pages/actions, but the `vector-sticky-header-enabled` CSS class responsible for adding extra space to account for the height of a sticky header remains on the `html` element.
The easiest solution is to make the JS remove the `vector-sticky-header-enabled` class if the namespace or action doesn't allow a sticky header. But this would result in a possible layout shift of the sticky elements (TOC, page tools, etc).
Therefore, the best solution in terms of user experience, SEO, and performance is to move the client-side logic responsible for determining whether the sticky header should show to the back-end. If the page doesn't allow the sticky header, the `vector-sticky-header-enabled` class should not be added to the `html` element.