fix: Fix the scroll position of request body [INS-1105] (#8962)

This commit is contained in:
xdm
2025-08-13 12:19:12 +08:00
committed by GitHub
parent b42bd96958
commit bdbd45e8f0

View File

@@ -306,8 +306,13 @@ export const CodeEditor = memo(
// NOTE: maybe we don't need this anymore? Maybe not.
const persistState = useCallback(() => {
if (uniquenessKey && codeMirror.current) {
const scrollInfo = codeMirror.current.getScrollInfo();
// ignore invalid scroll positions
if (scrollInfo.height <= 0 || scrollInfo.width <= 0) {
return;
}
editorStates[uniquenessKey] = {
scroll: codeMirror.current.getScrollInfo(),
scroll: scrollInfo,
selections: codeMirror.current.listSelections(),
cursor: codeMirror.current.getCursor(),
history: codeMirror.current.getHistory(),