Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent “half screen” bug by resetting scroll position when editor regains focus #798

Conversation

savetheclocktower
Copy link
Contributor

Identify the Bug

See #191.

Description of the Change

Pulsar uses a hidden input element to receive keyboard input in text editors.

When this hidden element is outside the current viewport, sometimes the browser tries to scroll a container that isn't meant to be scrolled in order to bring it into view. This doesn't make sense because of how we handle scrolling, so it's always the wrong thing to do, even though the browser's just trying to be helpful.

Atom used to handle this by explicitly resetting the container's scrollTop and scrollLeft to 0 after the hidden input was focused, but this PR changed that behavior because of a mistaken belief that it wouldn't be needed anymore.

Alternate Designs

You can read about other possible fixes in #191. I think we settled on this one because it's just restoring a fix that Atom used to have, so it's less risky than trying a novel approach that might introduce new regressions.

Possible Drawbacks

I honestly doubt that there are any. If this code caused any problems, it wouldn't have been previously present in Atom.

Verification Process

Perform the reproduction steps in #191 and verify that the issue no longer occurs.

Release Notes

Fixed an issue that sometimes caused text to shift or disappear after an editor pane regains focus.

…when an editor regains focus.

This used to happen until the change in <atom/atom#20892>. But we still need this code, presumably because of built-in browser behavior that _implicitly_ scrolls the editor's container to try to move the hidden input back into view.
@savetheclocktower savetheclocktower linked an issue Nov 13, 2023 that may be closed by this pull request
5 tasks
@bobemoe
Copy link

bobemoe commented Nov 13, 2023

Also fixes #355

Copy link
Contributor

@mauricioszabo mauricioszabo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see absolutely no problem with this, let's get this merged and see if it fixes the issue!

If not, we can always revert - if you want, please add a CHANGELOG too, because this needs to be mentioned - it's such a weird bug and the fix is so... simple... it amazes me!

@savetheclocktower savetheclocktower merged commit 69c0e61 into pulsar-edit:master Nov 13, 2023
@savetheclocktower savetheclocktower deleted the fix-half-screen-bug-we-think branch November 13, 2023 21:58
@bobemoe bobemoe mentioned this pull request Nov 23, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strange "half screen" error in editor
3 participants