Sfoglia il codice sorgente

临时代码,收起建议面板的时候删除DOM

visuddhinanda 3 anni fa
parent
commit
cdfc444649
1 ha cambiato i file con 14 aggiunte e 11 eliminazioni
  1. 14 11
      dashboard/src/components/template/SentEdit/SuggestionTabs.tsx

+ 14 - 11
dashboard/src/components/template/SentEdit/SuggestionTabs.tsx

@@ -12,14 +12,13 @@ interface IWidget {
 const Widget = ({ data }: IWidget) => {
   const [value, setValue] = useState("close");
   const [showPanel, setShowPanel] = useState("none");
-  const [showSuggestion, setShowSuggestion] = useState("none");
+  const [showSuggestion, setShowSuggestion] = useState(false);
 
   const onChange = ({ target: { value } }: RadioChangeEvent) => {
     console.log("radio1 checked", value);
     switch (value) {
       case "suggestion":
-        setShowSuggestion("block");
-        setShowPanel("block");
+        setShowSuggestion(true);
         break;
     }
     setValue(value);
@@ -60,15 +59,19 @@ const Widget = ({ data }: IWidget) => {
           <Radio value="close" style={{ display: "none" }}></Radio>
         </Radio.Group>
       </div>
-      <div style={{ display: showPanel }}>
-        <div style={{ display: showSuggestion, paddingLeft: "1em" }}>
-          <div>
-            <SuggestionAdd data={data} />
-          </div>
-          <div>
-            <SuggestionList {...data} />
+      <div>
+        {showSuggestion ? (
+          <div style={{ paddingLeft: "1em" }}>
+            <div>
+              <SuggestionAdd data={data} />
+            </div>
+            <div>
+              <SuggestionList {...data} />
+            </div>
           </div>
-        </div>
+        ) : (
+          <></>
+        )}
       </div>
     </div>
   );