scrollViewportToShowTarget() should avoid scrolling window if unecessary
📝 Provide detailed reproduction steps (if any)
- Go to https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/features/table-of-contents.html.
- Set
max-height: 400andoverflow: hiddenon the editing root. - Use ToC to navigate.
✔️ Expected result
If the heading can be revealed just by scrolling the root, the window scroll should stay intact.
❌ Actual result
The helper touches both even though scrolling window does not make any sense.
❓ Possible solution
This is probably caused by alignToTop = true, forceScroll = true used by ToC. The algorithm always wants to have the heading near the top of a viewport, only considering the config.ui.viewportOffset and the Classic editor toolbar height.
If a target (heading) is in a scrollable ancestor(s), alignToTop = true, forceScroll = true should treat the outermost scrollable ancestor as a viewport, and align there, then scroll the actual viewport (window) only if necessary to display the heading to the user. This may require some refactoring and additional modularity in the toolset.
If you'd like to see this fixed sooner, add a 👍 reaction to this post.
There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.
We've closed your issue due to inactivity. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).