Mobile: Fixes #15116: Fix markdown editor not scrolling to search results (#15119)

This commit is contained in:
Sriram Varun Kumar authored and GitHub committed 2026-04-16 11:52:55 +01:00
1 parent babea9f388
commit 400dc70f32
1 file changed
+13
@@ -174,6 +174,19 @@ const searchExtension = (onEvent: OnEventCallback, settings: EditorSettings): Ex
},
} : undefined),
// On mobile, scrolling is handled externally (page-level native scroll), so
// .cm-scroller has no internal scroll. A @codemirror/view upgrade (6.35→6.41)
// added rect-clipping after each failed scroll attempt, which prevents the
// fallback window.scrollBy from firing. Use native element.scrollIntoView to
// fix findNext/findPrevious and GoDocEnd.
settings.useExternalSearch ? EditorView.scrollHandler.of((view, range) => {
const { node } = view.domAtPos(range.head);
const el = node.nodeType === Node.ELEMENT_NODE ? node as Element : node.parentElement;
if (!el) return false;
el.scrollIntoView({ block: 'nearest', inline: 'nearest' });
return true;
}) : [],
autoScrollToMatchPlugin,
EditorState.transactionExtender.of((tr) => {