Unwanted programmatic scrolling with large widgets

Hej,

I have a large widget (a long Markdown table, rendered to HTML) which also allows users to edit parts of the underlying source code (individual table cells) using subviews. While moving the cursor across the widget, the main editor (that holds the table widget) will frequently jump to the beginning or the end of the widget itself, instead of just keeping the scroll position where it is. This is likely due to the fact that for a brief moment, the focus lies in the main document and the editor attempts to move either the beginning of the widget range, or the end of it, into view. (Once I type, the editor jumps back to the currently editing table cell.)

Is there a way to prevent this jumping behavior for large widgets programmatically? Ideally something that I can turn on and off with a state effect? Then I could just do some detection on my side and tell the main editor to not jump around in this instance.

Thanks in advance!

Keeping focus out of the outer editor seems like the way to go here. Why is it briefly ending up in there?

Is there a way to prevent the editor “grabbing” focus when the selection changes? The issue is that I want the main (outer) editor to be the source of truth for the data in the table widget. This means that, whenever a user clicks inside a cell to edit it, I set the selection in the outer editor. This then triggers an update in the widget, which then sees that the selection is within a cell, and mounts a sub EditorView inside that cell to allow editing of just that cell. Additionally, all transactions are shared between both views so that the outer editor at all times has perfect knowledge about whatever the user changes inside that table widget.

But for that to work, I need to change the selection in the outer editor, which is when the outer editor will briefly capture focus before the subview is mounted and likewise can grab the focus. As soon as one types in the subview, the editor will scroll to the correct table cell again.

Essentially, I need a way to programmatically set the selection in the outer editor, without it grabbing focus and jumping to different scroll positions. I already suspect that the solution is glaringly obvious and I just can’t see it …

The editor does not grab focus when selection changes. It’ll only mess with the DOM selection on a transaction if it already has focus. Is your inner widget focusable?