1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Desktop: Fixes #4797 (partially): Scroll position is not remembered in Markdown editor (#4806)

This commit is contained in:
Roman Musin 2021-04-25 09:52:05 +01:00 committed by GitHub
parent a4854fcde8
commit f87ff54e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,8 +70,13 @@ export function useScrollHandler(editorRef: any, webviewRef: any, onScroll: Func
if (editorRef.current) {
const percent = editorRef.current.getScrollPercent();
setViewerPercentScroll(percent);
if (!isNaN(percent)) {
// when switching to another note, the percent can sometimes be NaN
// this is coming from `gui/NoteEditor/NoteBody/CodeMirror/utils/useScrollUtils.ts`
// when CodeMirror returns scroll info with heigth == clientHeigth
// https://github.com/laurent22/joplin/issues/4797
setViewerPercentScroll(percent);
}
}
}, [setViewerPercentScroll]);