add TableOfContents and other 2.5.0 updates#275
Conversation
|
@AnnMarieW |
|
Thanks for the suggestion @deadkex I tried to add a clientside callback to the docs to handle the scroll to the hash on initial load and on refresh, but it's not working. It starts in the correct location, then scrolls to the top of the page. Have you implemented this feature in other projects? I'll also add an example of styling using the Styles API. You had a good example in your PR. |
|
This works for my website @AnnMarieW clientside_callback(
"""
function(event, hash) {
function scrollToHash(retries = 10) {
if (retries <= 0 || hash == '') return;
var targetId = hash.replace('#', '');
var target = document.getElementById(targetId);
if (target) {
target.scrollIntoView({ behavior: 'smooth' });
} else {
setTimeout(() => scrollToHash(retries - 1), 100);
}
}
scrollToHash();
return window.dash_clientside.no_update;
}
""",
Output(*AppIds.Page.div_toc_empty.children),
Input(*AppIds.App.url.pathname),
State(*AppIds.App.url.hash)
) |
|
Nice! That works great! Thanks so much 🥇 |
|
Huh, it works perfectly when I run it locally, but not when it's deployed on render 🤔 |
|
@AnnMarieW --Try clearing your browser cache, works for me on the dmc website-- |
|
@deadkex OK, I took the scroll-to hash out for now. I think it's better that it doesn't scroll rather than scrolling to some random position. |
WIP for the TableOfContents PR snehilvj/dash-mantine-components#513
Also added interactive example for PinInput