Ver Fonte

每次查新词,都先滚动到开始

visuddhinanda há 2 anos atrás
pai
commit
a5e04e24ea
1 ficheiros alterados com 3 adições e 0 exclusões
  1. 3 0
      dashboard/src/components/dict/Dictionary.tsx

+ 3 - 0
dashboard/src/components/dict/Dictionary.tsx

@@ -20,6 +20,7 @@ const DictionaryWidget = ({ word, compact = false, onSearch }: IWidget) => {
   useEffect(() => {
     if (word !== wordSearch) {
       setWordSearch(word?.toLowerCase());
+      document.getElementById("pcd_dict_top")?.scrollIntoView();
     }
   }, [word]);
 
@@ -27,12 +28,14 @@ const DictionaryWidget = ({ word, compact = false, onSearch }: IWidget) => {
     console.log("onSearch", value);
     const word = value.toLowerCase();
     setWordSearch(word);
+    document.getElementById("pcd_dict_top")?.scrollIntoView();
     if (typeof onSearch !== "undefined") {
       onSearch(value, isFactor);
     }
   };
   return (
     <div ref={setContainer}>
+      <div id="pcd_dict_top"></div>
       <Affix offsetTop={0} target={compact ? () => container : undefined}>
         <div
           style={{