Преглед на файлове

搜索到第一个标题就停止

visuddhinanda преди 2 години
родител
ревизия
f5d979836b
променени са 1 файла, в които са добавени 3 реда и са изтрити 10 реда
  1. 3 10
      dashboard/src/components/article/PaliTextToc.tsx

+ 3 - 10
dashboard/src/components/article/PaliTextToc.tsx

@@ -30,24 +30,17 @@ const PaliTextTocWidget = ({ book, para, channel, onSelect }: IWidget) => {
       });
       });
       setTocList(toc);
       setTocList(toc);
       if (json.data.rows.length > 0) {
       if (json.data.rows.length > 0) {
-        let currLevel = 0;
         let path: string[] = [];
         let path: string[] = [];
         for (let index = json.data.rows.length - 1; index >= 0; index--) {
         for (let index = json.data.rows.length - 1; index >= 0; index--) {
           const element = json.data.rows[index];
           const element = json.data.rows[index];
-          if (element.book === book && element.paragraph === para) {
-            currLevel = parseInt(element.level);
-          }
-          if (
-            parseInt(element.level) === 1 ||
-            (element.book === book && parseInt(element.level) < currLevel)
-          ) {
-            currLevel = parseInt(element.level);
+          if (element.book === book && para && element.paragraph <= para) {
             path.push(`${element.book}-${element.paragraph}`);
             path.push(`${element.book}-${element.paragraph}`);
+            break;
           }
           }
         }
         }
         setExpandedKeys(path);
         setExpandedKeys(path);
+        setSelectedKeys(path);
       }
       }
-      setSelectedKeys([`${book}-${para}`]);
     });
     });
   }, [book, para]);
   }, [book, para]);