-
Notifications
You must be signed in to change notification settings - Fork 36
add TableOfContents #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add TableOfContents #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-- |
WIP for the TableOfContents PR snehilvj/dash-mantine-components#513
Also added interactive example for PinInput