Explorar el Código

Merge pull request #1875 from visuddhinanda/agile

add onSearch in <Dictionary />
visuddhinanda hace 2 años
padre
commit
078ed8b6f3

+ 10 - 1
dashboard/src/components/dict/DictComponent.tsx

@@ -19,7 +19,16 @@ const DictComponentWidget = ({ word }: IWidgetDict) => {
     }
   }, [searchWord]);
 
-  return <Dictionary word={wordSearch} compact={true} />;
+  return (
+    <Dictionary
+      word={wordSearch}
+      compact={true}
+      onSearch={(value: string) => {
+        console.debug("onSearch", value);
+        store.dispatch(lookup(value));
+      }}
+    />
+  );
 };
 
 export default DictComponentWidget;

+ 5 - 1
dashboard/src/components/dict/Dictionary.tsx

@@ -117,7 +117,11 @@ const DictionaryWidget = ({ word, compact = false, onSearch }: IWidget) => {
                 onIdChange={(value: string) => {
                   const newInput = `type:term id:${value}`;
                   console.debug("term onIdChange setWordInput", newInput);
-                  setWordInput(newInput);
+                  if (typeof onSearch !== "undefined") {
+                    onSearch(newInput);
+                  } else {
+                    setWordInput(newInput);
+                  }
                 }}
               />
             )}