-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Addon Docs: Fix scroll and highlight #26470
base: next
Are you sure you want to change the base?
Conversation
In docs page, if you click on a table-of-contents item, and there is not enough height available in the docs page, it does not change the current state of the table-of-contents. To fix this bug a blank space is added at the end of the page to give it enough height.
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 843e70c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty!
The proposed solution looks worse than the problem to me. There is now a page's worth of blank space on pages where the issue occurs: I suggest a fix be found inside tocbot instead. The situation described in the issue is supposed to have an option for handling it (see https://tscanlin.github.io/tocbot/#troubleshooting), which does not work. |
That troubleshooting tip is meant for TOC's with lots of items not one with two items like you have here so I'd say that it doesn't really apply or help here. I have addressed this previously for another user that had a similar question here: Having whitespace at the bottom of the document to handle this may not seem ideal but I can't think of another way to handle this that's better, can you @Sidnioulz? |
Thanks for the context Tim!
I have one but it will need a lot more work :) Let's start with what we know/assume:
What we can easily deduce:
My proposal is to apply another logic for handling these last few items starting from the threshold. It should trigger on two conditions:
When the new logic triggers (item clicked or API call with valid anchor):
These JS computations should be acceptable performance-wise:
When to resume the original logic (highlight on scroll only)?
What other events should/could occur?
TL;DR: The current logic has a blind spot that cannot be avoided; an alternative logic needs to be used and crafting it will require significant work. |
Sorry for the delay @Sidnioulz I was busy with family stuff and was out of town due to the holidays. I think it fulfills the requirements of making the other links clickable without having to scroll to them. It also allows for programatic changing as well using a hash change listener. Let me know if you have any feedback. |
Closes #26347
What I did
In docs page, if you click on a table-of-contents item, and there is not enough height available in the docs page, it does not change the current state of the table-of-contents. To fix this bug a blank space is added at the end of the page to give it enough height. To add a blank space I created a constant 'Spacer' and then, when the table of contents is exported it's returned this constant.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>