DEV Community

Samuel Pérez
Samuel Pérez

Posted on

“The page jumps up when clicking on buttons in a JavaScript calendar

I'm developing a calendar in vanilla JavaScript connected to a Node.js backend.

I'm having a strange bug on the frontend:

  • When clicking calendar buttons, the page scrolls up,
  • The calendar re-renders after each action,
  • and there seems to be a problem with the DOM scrolling or re-rendering.

The calendar is dynamically rebuilt using:

  • innerHTML
  • createElement
  • XMLHttpRequest

I've already tried:

  • type="button"
  • preventDefault()
  • stopPropagation()

but the problem persists.

Has anyone encountered a similar bug related to re-rendering or scroll position loss?

I've attached a video of the behavior.

Top comments (0)