From ca772a9b73f6bbc5f4eb88c4e9a4b1e3b54d06ec Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Fri, 23 Oct 2020 01:48:02 +0300
Subject: [PATCH] autofocus

---
 .../src/components/findAndReplace/FindComponent.js     |  7 +++++++
 .../DisplayTextToolGroupService/DisplayText.js         | 10 +++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js b/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js
index bb5ecc8c5..902b9f641 100644
--- a/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js
+++ b/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js
@@ -84,6 +84,7 @@ const FindComponent = ({ close, expand, setPreviousSearcValue }) => {
   const [searchValue, setSearchValue] = useState('');
   const [counterText, setCounterText] = useState('0 of 0');
   const findAndReplacePlugin = app.PmPlugins.get('findAndReplacePlugin');
+  const [isFirstRun, setFirstRun] = useState(true);
   const allStates = [];
 
   each(view, (singleView, viewId) => {
@@ -101,6 +102,12 @@ const FindComponent = ({ close, expand, setPreviousSearcValue }) => {
 
   useEffect(() => {
     delayedSearch();
+    if (isFirstRun) {
+      setTimeout(() => {
+        searchRef.current.focus();
+        setFirstRun(false);
+      });
+    }
   }, [searchValue, delayedSearch, JSON.stringify(allStates)]);
 
   const searchDocument = () => {
diff --git a/wax-prosemirror-services/src/WaxToolGroups/DisplayTextToolGroupService/DisplayText.js b/wax-prosemirror-services/src/WaxToolGroups/DisplayTextToolGroupService/DisplayText.js
index 5618610d1..0ad922f8c 100644
--- a/wax-prosemirror-services/src/WaxToolGroups/DisplayTextToolGroupService/DisplayText.js
+++ b/wax-prosemirror-services/src/WaxToolGroups/DisplayTextToolGroupService/DisplayText.js
@@ -51,11 +51,11 @@ class DisplayText extends ToolGroup {
 
     const tabList = [first, second];
 
-    // const TabsComponent = useMemo(
-    //   () => <Tabs key={uuidv4()} tabList={tabList} />,
-    //   [],
-    // );
-    return <Tabs key={uuidv4()} tabList={tabList} />;
+    const TabsComponent = useMemo(
+      () => <Tabs key={uuidv4()} tabList={tabList} />,
+      [],
+    );
+    return TabsComponent;
   }
 }
 
-- 
GitLab