The discussion highlights an issue with the DiscoTOC style on mobile devices when there are no replies in a topic. Don explains that the .with-topic-progress class, which triggers the DiscoTOC style, is only added if there is more than one post. This causes the TOC to break on mobile, although it works fine on desktop. JammyDodger confirms encountering the same issue. alltiagocom provides a custom solution using CSS and JavaScript to make the TOC sticky and visible even without replies. Don suggests a CSS-only approach by applying the same styles to .topic-navigation as those used for .with-topic-progress. chapoi mentions that this issue should be fixed with a pull request on GitHub.
DiscoTOC style is connected to the .with-topic-progress class which is added to .topic-navigation if there are more than 1 post in the topic. So without reply the DiscoTOC style will broke.
I think TOC should also be active if there is no reply in a topic because it doesn’t related with the reply counts. On desktop it works fine topics with no reply too.
I’ve just run into this here too. (iPhone/Safari) It’d be great if this could be fixed. Scrolling to the bottom of a long doc to get to the toc is a bit cumbersome.
Dit lijkt prima te werken, zelfs zonder een reactie.
Nogmaals, ik ben geen expert, ik ben gewoon een goede “vrager” en na een beetje “heen en weer” met ChatGPT met de juiste vragen en uitdagingen, lijkt het te werken.
Als iemand die een expert is in JavaScript en CSS het wil verbeteren, deel het alsjeblieft.
Dus, als je wilt:
De tekst “Table of Contents” naast het icoon
Uitgevouwen koppen
Sticky knop zonder afhankelijk te zijn van reacties, is de volledige CSS dit:
/* breidt alle koppen uit in de zijbalk van de inhoudsopgave */
#d-toc li.d-toc-item > ul {
max-height: 500em !important;
overflow: visible !important;
opacity: 1 !important;
}
@media screen and (max-width: 767px) {
/* maakt de wrapper inclusief de knop van de inhoudsopgave, sticky aan de onderkant */
#topic-progress-wrapper.sticky-bottom {
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 1000;
}
/* voegt "table of contents" toe aan de knop na het icoon */
.d-toc-mini button::after {
content: "Table of Contents";
margin-left: 5px;
font-size: 14px;
vertical-align: middle;
}
}
This is great thanks, but I think we can make it with only CSS too. We just have to use the same CSS on .topic-navigation which used on .with-topic-progress. The missing .with-topic-progress class is blocking the style if there is no reply in the topic.