-
-
Notifications
You must be signed in to change notification settings - Fork 371
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
Getting scrolling (e.g. on typing) to work in virtualized lists #1355
Comments
I am checking if the new |
No, I can still use My current solution comes down to: ViewPlugin.define((view) => {
return {
update: () => {
// @ts-ignore
const scrollTarget = view.viewState.scrollTarget;
if (scrollTarget) {
scrollVirtualizedListToEditor(scrollTarget);
}
}
};
}) or equivalently: EditorView.updateListener.of((viewUpdate) => {
// @ts-ignore
const scrollTarget = viewUpdate.view.viewState.scrollTarget;
if (scrollTarget) {
scrollVirtualizedListToEditor(scrollTarget);
}
}) Would you consider exposing ViewPlugin.define((view) => {
return {
scroll: (scrollTarget: ScrollTarget) => {
scrollVirtualizedListToEditor(scrollTarget);
}
};
}) |
FEATURE: The `EditorView.scrollHandler` facet can be used to override or extend the behavior of the editor when things are scrolled into view. Issue codemirror/dev#1355
Does patch codemirror/view@1ecb5f1 look like it would work for you? |
Yes, this looks like it should do it, thank you! |
Released as part of @codemirror/view 6.26.0 |
Describe the issue
When I type in the editor which is out of view, the container in which it is embedded is scrolled revealing the editor. This is thanks to internal CodeMirror logic. This logic calls
DocView.scrollIntoView()
which in turn callsscrollRectIntoView()
method. ThescrollRectIntoView
tries hard to find out which parent element needs to be scrolled and it succeeds even for the virtualized lists. However, the delta needed to scroll is wrong when the CodeMirror editor is embedded in a virtualized list. This is not surprising -scrollRectIntoView
cannot know how much to scroll if some of the elements are hidden by virtualization.It is currently impossible to cleanly hook into
scrollRectIntoView
in order to scroll the virtualized list to reveal editor. It is also not possible to listen to consequences ofscrollRectIntoView
and intervene becausescrollTop
used byscrollRectIntoView
emits a plain event which is indistinguishable from native scroll events invoked by user (and which does not carry the underlying information about the scroll target).To support the use case of embedding CodeMirror in virtualized lists it would be sufficient if
scrollIntoView
had a callback/event called/emitted beforescrollRectIntoView
is called (which would include the scroll target info). The virtualized list owner could then scroll the virtualized list revealing the editor.Is this a use-case that could be supported?
Browser and platform
No response
Reproduction link
No response
The text was updated successfully, but these errors were encountered: