Try it on https://wikimedia.github.io/VisualEditor/demos/ve/minimal.html
- Enter new lines in editor until the page starts to scroll vertically
- Observe the toolbar becoming a vertical mess on the top left of the page
- Bonus: With jquery3 obtain an exception due to a call of offset() on a non-DOM element.
The problem originates from toolbar initialization happening in addSurface(), but the element needs to be in the DOM to initialize element offsets properly.
A solution is to add the Target to the DOM before adding the Surface. See https://github.com/wikimedia/VisualEditor/blob/9be803f37cff257d11f563f07573204d23cf2053/demos/ve/demo.minimal.js#L25-L26
These lines should move up to line 16.