Skip to content

Progress bar script throws "Cannot read properties of null" on every page (invalid selector in general_scripts.html) #800

Description

@Shruti2110-coder

Describe the bug
Every page of the Interactive Book throws an uncaught TypeError on scroll:
"Cannot read properties of null (reading 'getBoundingClientRect')" at
animateProgressBar. As a result, the reading progress bar at the top of
the page never fills in — it stays stuck at 0% width.

To Reproduce

  1. Go to 'https://learn.circuitverse.org/docs/binary-representation/binary-numbers.html' (or any page)
  2. Open DevTools Console
  3. Scroll down the page
  4. See error logged on every scroll event

Expected behavior
The progress bar should fill smoothly as the user scrolls, with no console errors.

Desktop:

  • OS: macOS
  • Browser: Chrome
  • Version: [check chrome://version if you want exact number]

Root cause
In _includes/general_scripts.html, document.querySelector('#main-content-wrap')
uses an id selector, but the actual element only has class="main-content-wrap"
so the query returns null and every scroll throws.

Proposed fix
Change #main-content-wrap to .main-content-wrap in the querySelector call.
Happy to submit a PR for this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions