Mao 4 лет назад
Родитель
Сommit
f3238d9632

+ 1 - 3
packages/app/src/components/SearchPage.jsx

@@ -105,12 +105,10 @@ class SearchPage extends React.Component {
 
   onSelectPageToShowInvoked= (pageId) => {
     // TODO : this part can be improved.
-    // pageId is this form: #id_613eda3717b2d80c4874dfb9
     let index;
     let i = 0;
-    const pId = pageId.slice(4);
     this.state.searchedPages.forEach((page) => {
-      if (pId === page._id) { index = i }
+      if (pageId === page._id) { index = i }
       i++;
     });
     this.setState({

+ 1 - 2
packages/app/src/components/SearchPage/SearchResultContent.jsx

@@ -10,8 +10,7 @@ const SearchResultContent = (props) => {
     let showTags = false;
     if (page.tags != null && page.tags.length > 0) { showTags = true }
     return (
-      // Add prefix 'id_' in id attr, because scrollspy of bootstrap doesn't work when the first letter of id of target component is numeral.
-      <div id={`id_${page._id}`} key={page._id} className="search-result-page mb-5">
+      <div key={page._id} className="search-result-page mb-5">
         <h2>
           <a href={page.path} className="text-break">
             {page.path}

+ 2 - 2
packages/app/src/components/SearchPage/SearchResultList.jsx

@@ -7,10 +7,10 @@ class SearchResultList extends React.Component {
   render() {
     return this.props.pages.map((page) => {
       // Add prefix 'id_' in pageId, because scrollspy of bootstrap doesn't work when the first letter of id attr of target component is numeral.
-      const pageId = `#id_${page._id}`;
+      const pageId = `#${page._id}`;
       return (
         <li key={page._id} className="nav-item page-list-li w-100 m-0 border-bottom">
-          <a className="nav-link page-list-link d-flex align-items-baseline" href={pageId} onClick={() => { this.props.clickHandler(pageId) }}>
+          <a className="nav-link page-list-link d-flex align-items-baseline" href={pageId} onClick={() => { this.props.clickHandler(page._id) }}>
             <div className="form-check my-auto">
               <input className="form-check-input my-auto" type="checkbox" value="" id="flexCheckDefault" />
             </div>