Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hidden sidebar causing other plugins issues #1392

Closed
1 task done
markbattistella opened this issue Oct 13, 2020 · 4 comments
Closed
1 task done

Hidden sidebar causing other plugins issues #1392

markbattistella opened this issue Oct 13, 2020 · 4 comments
Labels
bug confirmed as a bug

Comments

@markbattistella
Copy link
Contributor

Bug Report

Steps to reproduce

  1. Setup fresh site
  2. Add config:
    window.$docsify = {
      name: '',
      repo: '',
    
      // cover page doc
      coverpage: true,
      homepage: 'home.md',
    
      // remove sidebar
      hideSidebar: true,
    
      // auto scroll to top
      auto2top: true
    }
  3. Create two or more md pages:
    1. home.md -- add 2x href to page1 and page2
    2. page1.md -- add 2x href to home and page2
    3. page2.md -- add 2x href to home and page1
  4. Launch http://localhost:3000
  5. From /#/home in console no errors
    1. Click on page1 link
    2. Continue to cycle through pages without hard refresh

What is current behaviour

After first load and the sidebar is removed, any other navigation to other pages triggers the .remove which fails since the element is already gone.

If the error is hit, then following plugins dont run until a hard reload.

Uncaught TypeError: Cannot read property 'remove' of null
    at Vn.Xn._renderSidebar (docsify.min.js:1)
    at Vn.Pn (docsify.min.js:1)
    at docsify.min.js:1
    at o (docsify.min.js:1)
    at B (docsify.min.js:1)
    at t (docsify.min.js:1)
    at docsify.min.js:1
    at docsify.min.js:1
    at docsify.min.js:1
    at On (docsify.min.js:1)
Line 4150: return document.querySelector("aside.sidebar").remove(),

What is the expected behaviour

Error doesn't occur, and doesn't stop other scripts from running.

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Your OS: macOS

  • Node.js version: 14.8.0

  • npm/yarn version: 6.14.8

  • Browser version:

  • Docsify version: 4.11.6

  • Docsify plugins:

@sy-records
Copy link
Member

sy-records commented Oct 13, 2020

If you have a hideSidebar, why do you need to operate the sidebar?


Okay, I see fixme, any new ideas? @anikethsaha

// FIXME : better styling solution
document.querySelector('aside.sidebar').remove();
document.querySelector('button.sidebar-toggle').remove();
document.querySelector('section.content').style.right = 'unset';
document.querySelector('section.content').style.left = 'unset';
document.querySelector('section.content').style.position = 'relative';
document.querySelector('section.content').style.width = '100%';

@anikethsaha
Copy link
Member

Yes, I was not 100% comfortable with styling like these. so marked as fixme inorder to re-iterate here again.

@anikethsaha anikethsaha added the bug confirmed as a bug label Oct 13, 2020
@sy-records sy-records linked a pull request Oct 14, 2020 that will close this issue
19 tasks
@markbattistella
Copy link
Contributor Author

@sy-records I was making a single page layout with hard coded navigation and noticed that other plugins weren't loading. Everything was stopping after the .remove was failing since the sidebar was already hidden and removed

@jhildenbiddle
Copy link
Member

This issue has been addressed by PR #2469. The changes will be available when Docsify v5 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed as a bug
Projects
None yet
4 participants