Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix(editor): prevent race condition and ensure correct list continuation on Enter (#4716)
Jonathan Fok kan7c05a9b997bc
diff --git a/web/src/components/MemoEditor/Editor/index.tsx b/web/src/components/MemoEditor/Editor/index.tsxindex 193815578..35c02909c 100644--- a/web/src/components/MemoEditor/Editor/index.tsx+++ b/web/src/components/MemoEditor/Editor/index.tsx@@ -169,6 +169,11 @@ const Editor = forwardRef(function Editor(props: Props, ref: React.ForwardedRef<if (event.shiftKey || event.ctrlKey || event.metaKey || event.altKey) {return;}+ // Prevent a newline from being inserted, so that we can insert it manually later.+ // This prevents a race condition that occurs between the newline insertion and+ // inserting the insertText.+ // Needs to be called before any async call.+ event.preventDefault();const cursorPosition = editorActions.getCursorPosition();const prevContent = editorActions.getContent().substring(0, cursorPosition);@@ -205,9 +210,7 @@ const Editor = forwardRef(function Editor(props: Props, ref: React.ForwardedRef<insertText += " |";}- if (insertText) {- editorActions.insertText(insertText);- }+ editorActions.insertText("\n" + insertText);}};