From 92a76df4a209abd107e5a4680fd28cf44ba94d11 Mon Sep 17 00:00:00 2001
From: Dennis Collaris <d.collaris@me.com>
Date: Thu, 24 Oct 2024 21:11:36 +0200
Subject: [PATCH] fix: focus editor before inserting

---
 .../components/textEditor/plugins/InsertVariablesPlugin.tsx    | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx b/libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx
index c6932a3b6..afe7016cc 100644
--- a/libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx
+++ b/libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx
@@ -12,6 +12,9 @@ export const InsertVariablesPlugin = () => {
 
   const onChange = (value: string | number, type: VariableType) => {
     editor.update(() => {
+      const editorElement = document.querySelector('.editor > div') as HTMLDivElement;
+      editorElement?.focus();
+
       const selection = $getSelection() as BaseSelection;
 
       const node = new VariableNode(String(value), type);
-- 
GitLab