From e18e945cd31bb017233ed75a2bf5cb60d9db4e2a Mon Sep 17 00:00:00 2001
From: David Luzar <luzar.david@gmail.com>
Date: Thu, 4 Feb 2021 14:54:00 +0100
Subject: [PATCH] fix: incorrect z-index of text editor (#2914)

---
 src/components/App.tsx      | 1 +
 src/element/textWysiwyg.tsx | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/components/App.tsx b/src/components/App.tsx
index fcd0bd15..fd6759fb 100644
--- a/src/components/App.tsx
+++ b/src/components/App.tsx
@@ -454,6 +454,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
           renderCustomFooter={renderFooter}
           viewModeEnabled={viewModeEnabled}
         />
+        <div className="excalidraw-textEditorContainer" />
         {this.state.showStats && (
           <Stats
             appState={this.state}
diff --git a/src/element/textWysiwyg.tsx b/src/element/textWysiwyg.tsx
index 2278ca1c..c8557665 100644
--- a/src/element/textWysiwyg.tsx
+++ b/src/element/textWysiwyg.tsx
@@ -160,7 +160,7 @@ export const textWysiwyg = ({
 
     unbindUpdate();
 
-    document.body.removeChild(editable);
+    editable.remove();
   };
 
   const rebindBlur = () => {
@@ -206,7 +206,9 @@ export const textWysiwyg = ({
     passive: false,
     capture: true,
   });
-  document.body.appendChild(editable);
+  document
+    .querySelector(".excalidraw-textEditorContainer")!
+    .appendChild(editable);
   editable.focus();
   editable.select();
 };