Problem/Motivation
I've noticed a problem with Tocbot when using it in Drupal 11.3, I first thought it were my settings or theme specific css but that doesn't seem to be the case.
I could reproduce this in three different environments, with different theming and tocbot settings:
- My own environment
- A clean Drupal 11 install
- A clean Drupal 11 install with the umami profile installed
I also tested this with tocbot from CDN and tocbot installed locally with composer (latest version).
I've recorded 3 videos to illustrate.
Steps to reproduce
Install Tocbot, set it up as you would and touch the scroll.
Comments
Comment #2
f0ns commentedI'm now testing with the latest Tocbot library version, I perhaps could test with older library versions and see if it's library specific or not to rule that out.
Comment #3
f0ns commentedTested with some older Tocbot libraries but all three instances have the same issue.
I have already debugged so much that I don't know where to look anymore to be honest.
Will look into the
tocbot-init.jsonce more. If I don't find anything there I think a fresh pair of eyes/someone smarter than me is needed.Comment #4
f0ns commentedAfter a lot of debugging I think I found the issue.
When I set
options.headingsOffset = 1;in the
tocbot-init.jsfile just beforetocbot.init()everything works great. Looks like it gets passed as text instead of a number and Tocbot doesn't throw an error and just doesn't work well then.I'll dig deeper and look for a patch but if anyone else has this issue in the meantime this information could be helpful.
Comment #5
f0ns commentedCasting all properties that are numbers to an int (interpreted as a string otherwise) fixed it for me.
https://git.drupalcode.org/issue/tocbot-3547569/-/commit/4d1066e82927f51...
Comment #6
f0ns commentedComment #9
svendecabooterThanks, fixed now.