Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
storeScrollPos / resetScrollPos conflict with Chrome scroll anchoring #933
ProseMirror tries to persist what part of a document is visible, even if above the visible viewport DOM nodes are added/removed. This functionallity is implemented in prosemirror-view in the storeScrollPos/resetScrollPos functions, also if the scrolling happens inside a container element other than the body.
Workaround is to set
Steps to reproduce
To reproduce in Chrome, simply put the editor into a fixed-height container with overflow auto, scroll somewhere to the middle of the document and instert something at the beginning:
Prosemirror view version 1.9.6
Hm. I expect that the Chrome behavior won't always work (when the node it uses as a reference is redrawn), but I guess it should usually be fine. There's
Trying to feature-detect this (with something like
I'll look into this more closely later.
Sorry I didnt get around to it when I said I would. But I now managed to find the problem.
TLDR: It was my own code.
More detailed: Im using https://www.npmjs.com/package/resize-detector to track size changes and was doing so on one of the editor's parent elments. In Firefox, there is no native ResizeObserver, so it falls back to adding a hidden element for tracking resize events, which caused the overflow-anchor not to work... Anyways: sorry for the confusion and thanks for the quick fix :)