Skip to content

Conversation

@Manas-Dikshit
Copy link

Overview

This PR modernizes and stabilizes the App Inventor control block definitions (controls_forRange, controls_forEach, and controls_do_then_return). It applies best practices for Blockly block construction, improves developer readability, and ensures consistent runtime behavior across environments.

Key Changes

Alignment Fixes
Replaced deprecated Blockly.inputs.Align.RIGHT with the correct Blockly.ALIGN_RIGHT constant across all block definitions.
Prevents initialization errors in current Blockly builds.

Safe Aliasing
Replaced reference assignment for controls_for alias with a deep clone via Blockly.utils.object.clone().
Ensures that future modifications to controls_forRange do not unintentionally propagate to controls_for.

Improved User Experience
Added default shadow numeric inputs (1 → 10 → 1) for FROM, TO, and BY fields in the forRange block.
Provides a cleaner, more informative default state when users drag the block into the workspace.

Code Modernization
Standardized ES module imports (import * as Blockly from 'blockly/core').
Ensured consistent indentation, naming, and field alignment.
Verified that tooltip and help URL keys remain intact and properly referenced in msg.js.

Comment Preservation
Retained the full historical comment log authored by Lyn and others.
Formatted and aligned historical notes for readability while maintaining attribution.

Structural Consistency
Unified all statement and value input sections for a coherent block layout.
Applied lexicalVariableScopeMixin consistently across loop blocks.

Benefits
Prevents runtime alignment errors in modern Blockly versions.
Improves maintainability and readability of control block source code.
Enhances user experience with sensible defaults.
Keeps full backward compatibility with existing projects.

Testing
Verified blocks load correctly in Blockly Developer Tools and App Inventor environment.
Confirmed that renaming, scoping, and flydown behaviors remain unchanged.
Confirmed tooltips, help URLs, and color styles are applied properly.

Notes
No functional regressions or UI-breaking changes introduced. This is a safe, internal refactor with visible improvements in UX and code quality.

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.

1 participant