Skip to content

[Bug] TypeError: Cannot read properties of null (reading 'children') in setSmallerLargerStatus on mouse wheel scroll #6436

@swapnachoudhary43

Description

@swapnachoudhary43

Description

When scrolling the mouse wheel on the canvas, the Service Worker
throws an uncaught TypeError in the console repeatedly, making
debugging difficult.

Error

Uncaught (in promise) TypeError: Cannot read properties of null 
(reading 'children')
    at Activity.setSmallerLargerStatus (activity.js:2188:43)
    at Activity._doSmallerBlocks (activity.js:2176:24)
    at doSmallerBlocks (activity.js:2145:28)
    at HTMLCanvasElement.__wheelHandler (activity.js:2525:55)

Steps to Reproduce

  1. Open https://musicblocks.sugarlabs.org/
  2. Open DevTools → Console tab (F12)
  3. Scroll mouse wheel on the canvas area
  4. Observe repeated TypeErrors in console

Expected Behavior

Mouse wheel scrolling should resize blocks smoothly with no
console errors.

Actual Behavior

setSmallerLargerStatus attempts to read .children on a null
element without a null check, causing repeated uncaught
TypeErrors on every scroll event.

Suggested Fix

Add a null guard in activity.js around line 2188:

// Before
someElement.children

// After  
if (someElement) {
    someElement.children
}

Environment

Checklist

  • I have read and followed the project's code of conduct.
  • I have searched for similar issues before creating this one.
  • I have provided all necessary information to reproduce the issue.
  • I am willing to contribute to the resolution of this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions