Skip to content

Commit

Permalink
Merge pull request #798 from savetheclocktower/fix-half-screen-bug-we…
Browse files Browse the repository at this point in the history
…-think

Prevent “half screen” bug by resetting scroll position when editor regains focus
  • Loading branch information
savetheclocktower authored Nov 13, 2023
2 parents 2658226 + 7bcf54a commit 69c0e61
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/text-editor-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,13 @@ module.exports = class TextEditorComponent {
}

didFocusHiddenInput() {
// Focusing the hidden input when it is off-screen causes the browser to
// scroll it into view. Since we use synthetic scrolling this behavior
// causes all the lines to disappear so we counteract it by always setting
// the scroll position to 0.
this.refs.scrollContainer.scrollTop = 0;
this.refs.scrollContainer.scrollLeft = 0;

if (!this.focused) {
this.focused = true;
this.startCursorBlinking();
Expand Down

0 comments on commit 69c0e61

Please sign in to comment.