Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Prevent the browser from auto-scrolling the scroll container on spacebar #16047
When the user is typing in the editor, we prevent the insertion of all characters into the hidden input except spaces. If we prevent the default action of space insertion, then the spacebar is interpreted by the browser as a request by the user to page down, so we have to insert it. Unfortunately, if the input is off screen, inserting a space causes the browser to attempt to scroll it into view. Since we implement our own scrolling, this causes content to become hidden.
This PR forces the scrollTop and scrollLeft of the scroll container back to 0 after typing a space in the editor. Often this will do nothing, but sometimes it will correct for the browser's auto-scroll behavior which we didn't want in the first place.