From c412926270ebbbf3637a608a2864ea0b4fedd2be Mon Sep 17 00:00:00 2001 From: Maciej Wasilewski Date: Thu, 26 Oct 2023 14:18:11 +0200 Subject: [PATCH] [#50692] Fix isFirstUser check when multiple editors are opened --- src/components/CodeMirror.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/CodeMirror.js b/src/components/CodeMirror.js index 439a507..c32d6c3 100644 --- a/src/components/CodeMirror.js +++ b/src/components/CodeMirror.js @@ -129,7 +129,12 @@ const CodeMirror = ({ text, setText, id, name, className, shown, syncText, setSy }, []); useEffect(() => { - const isFirstUser = collaboration.enabled && ytext.toString().length == 0 && provider.awareness.getStates().size == 1 && provider.firstUser && ready; + const mystEditorCount = document.querySelectorAll("#myst-css-namespace").length; + const isFirstUser = collaboration.enabled && + ytext.toString().length == 0 && + provider.awareness.getStates().size == mystEditorCount && + provider.firstUser && + ready; if (ytext && ytext.toString().length != 0) setText(ytext.toString());