Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue (required)
Closes #4234
Summary / motivation (required)
When the HTML editor (</>) is open and focused in the browser's note editor, switching to a different note and then scrolling and then clicking (anywhere) causes the view to jump back to the HTML editor's position. This happens because the
refocus()triggers both the browser's native scroll to focused element and CodeMirror's internal scroll to cursor behavior.The fix prevents scrolling during refocus in two places:
PlainTextInput.svelte: use focus({ preventScroll: true }) instead of editor.focus() in refocus() to prevent the browser from scrolling the focused element into viewcode-mirror.ts: pass { scroll: false } to setSelections() in the focus handler to prevent CodeMirror from internally scrolling to the restored cursor position.Steps to reproduce (required, use N/A if not applicable)
(Following the original issue instructions)
In the browser:
The view jumps to the position of the HTML editor where the focus was previously
How to test (required)
Follow the original issue related to this pull request. There is a video showing the problem.
Checklist (minimum)
./ninja checkor an equivalent relevant check locally.Details
Risk / compatibility / migration (optional)
Changes are scoped to two lines in two files. Only the refocus() code path is affected. User's focus behavior is unchanged.
Scope