When editing longer documents in blank.page, I sometimes find that the scroll position behaves erratically when you press Enter. Since I recently refactored blank.page removing old "scroll fixes", I knew (for once) that it was unlikely to be my fault.
But, in order to prove it beyond doubt, I had to create a new page with an empty textarea and no javascript, then I confirmed that the culprit was Chrome.
Here I'm pressing enter on new paragraphs, you will notice the scroll positions the caret on the top of the document.
The solution for this was to prevent the new line character from being inserted into the document, and inserting it via javascript instead. Unfortunately, this had the side effect of breaking undo. However, I found the way to properly modify/insert text via javascript while still keeping the undo stack, the code reads like this:
document.execCommand("insertText", false, "\n");
scroll(state.get("pageScroll"));
Where the first line makes the text insertion, and the second line scrolls back to the last known position, because I would get ocasional unexpected scrolls even with javascript's newline insertion.
Here is the editor with the change:
Usually I would not bend backwards to work around the mis-behavior of a browser, but this bug had been on Chrome for so long, and its behavior so important to blank.page, that I thought it would be better to patch things up.