Skip to content

Bug fixes: Null guard in repositionBlocks and _setupPaletteMenu#6446

Open
Shiv0087 wants to merge 1 commit intosugarlabs:masterfrom
Shiv0087:fix/null-guard-repositionBlocks-and-paletteMenu
Open

Bug fixes: Null guard in repositionBlocks and _setupPaletteMenu#6446
Shiv0087 wants to merge 1 commit intosugarlabs:masterfrom
Shiv0087:fix/null-guard-repositionBlocks-and-paletteMenu

Conversation

@Shiv0087
Copy link
Copy Markdown

@Shiv0087 Shiv0087 commented Mar 30, 2026

Type: Bug

Bug fixes: Null guard in repositionBlocks and _setupPaletteMenu

Problem

Two uncaught TypeErrors occur during scroll and resize:

  • Cannot read properties of undefined (reading 'blockList') in repositionBlocks
  • Cannot read properties of undefined (reading 'hide') in _setupPaletteMenu

Fix

Added null checks before accessing:

  • activity.blocks.blockList
  • this.boundary

Testing

No TypeErrors observed in console.

Copilot AI review requested due to automatic review settings March 30, 2026 13:16
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses two runtime TypeErrors triggered during scroll/resize by adding defensive guards before accessing properties that may not be initialized yet.

Changes:

  • Added early-return guard in repositionBlocks() when activity.blocks.blockList is unavailable.
  • Wrapped this.boundary.hide() in a null check to prevent calling hide() on undefined.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread js/activity.js
// FIX: guard against blocks not being initialized yet
if (!activity || !activity.blocks || !activity.blocks.blockList) {
return;
}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closing brace indentation is inconsistent (line 813 has extra leading whitespace), which makes the control flow harder to read and easy to mis-edit. Please align the braces/indentation with the surrounding style (i.e., } aligned with the if).

Suggested change
}
}

Copilot uses AI. Check for mistakes.
Comment thread js/activity.js
Comment on lines 818 to 822
//Array for storing individual dragGroups (the chunks of code linked together which are not connected)
const dragGroups = [];


// Identifying individual dragGroups
Object.values(activity.blocks.blockList).forEach(block => {
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment states there is an array for storing dragGroups, but the dragGroups declaration was removed in this hunk. Either restore the declaration (if it’s still used later in repositionBlocks) or update/remove the comment to avoid misleading future edits.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread js/activity.js
Comment thread js/activity.js
@Ashutoshx7
Copy link
Copy Markdown
Contributor

hy are u workiing on this

@Shiv0087
Copy link
Copy Markdown
Author

yes , men

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants