ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

scrollViewportToShowTarget() should avoid scrolling window if unecessary

Open oleq opened this issue 2 years ago • 1 comments

📝 Provide detailed reproduction steps (if any)

  1. Go to https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/features/table-of-contents.html.
  2. Set max-height: 400 and overflow: hidden on the editing root.
  3. 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.

oleq avatar Jun 15 '23 14:06 oleq

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.

CKEditorBot avatar Jun 15 '24 03:06 CKEditorBot

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).

CKEditorBot avatar Jul 16 '24 03:07 CKEditorBot