-
Notifications
You must be signed in to change notification settings - Fork 2
Live Preview Scroll Position Resets With Changes #3
Comments
This appears to be an issue with using a WKWebView inside an NSViewRepresentable, which rules out using a web view for the live preview. As an alternative, I'm testing MarkdownUI for the live preview. The largest hurdle is that MarkdownUI conforms to the CommonMark Spec, which does not include strikethrough syntax. Commit 97a7966 implements this, and I'll continue to test this to see if it's a viable alternative or if another solution is needed. |
- Fixed issue #3 by evaluating some JavaScript at key points during WKWebView's navigation lifecycle. See WebView.swift for the implementation.
As mentioned in commit fe718e5, I found a (buggy) way to fix my persistent scrolling issue. I describe how I implemented this in the source's documentation, but as a short summary:
This results in almost perfectly functional scroll restoration. I say "almost" because it isn't without bugs, which is why I'm leaving this issue open for now. If the user types too fast, or the JavaScript takes longer than expected to evaluate for some reason, then the live preview will briefly appear at the top of the document for a frame or two, then snap to the correct scroll position. If the user types fast enough, the live preview may go back to the top without resetting, since the view updates every time the document is updated. Since I want to keep working on other parts of this app and get it in people's hands, I'm going to just accept this solution for now. In the edge cases I outlined then the live preview won't act as expected, but as far as I can tell, this is the only solution that get's around |
See video below for example of the feature/bug in action: Screen.Recording.2022-01-06.at.2.48.23.AM.mov |
Describe the bug
When a document is edited and overflows past the length of the window, the live preview does not maintain the same scroll position as the editor window, resulting in the preview not displaying the portion of the document being edited.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The live preview should display the changes being made.
Screenshots
(Note the position of the scrollbar in the right-hand preview.)
Screen.Recording.2021-09-08.at.8.38.44.PM.mov
Device (please complete the following information):
The text was updated successfully, but these errors were encountered: