From 880d634dc817afe41296ae129856bf036ecf5da7 Mon Sep 17 00:00:00 2001 From: "JUST.in DO IT" Date: Wed, 4 Sep 2024 04:18:42 -0700 Subject: [PATCH] fix(sqllab): race condition when updating same cursor position (#30141) --- .../src/SqlLab/components/AceEditorWrapper/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx index 80ccc6ed1c07f..c77a7daf128ac 100644 --- a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx +++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx @@ -142,9 +142,15 @@ const AceEditorWrapper = ({ currentSelectionCache.current = selectedText; }); + editor.selection.on('changeCursor', () => { const cursor = editor.getCursorPosition(); - onCursorPositionChange(cursor); + const { row, column } = cursorPosition; + // Prevent a maximum update depth exceeded error + // by skipping repeated updates to the same cursor position + if (cursor.row !== row && cursor.column !== column) { + onCursorPositionChange(cursor); + } }); const { row, column } = cursorPosition;