Discuss Scratch

Koneko_koko-2
Scratcher
100+ posts

Issues with variable scope conversion and monitor checkbox UI desync between sprites

Hi Scratch Team and community,

Please note that I am using an AI translator to write this post, so I hope my description makes sense!

I have noticed two issues related to variables and monitor checkboxes in the latest version of Scratch. One causes deleted variables to change into local variables under certain conditions, and the other causes the stage monitors' checkboxes to experience a UI desync when switching between sprites.

Below are the detailed descriptions and reproduction steps for both issues.

### Issue 1: Deleted global variables are converted into local variables

When a global variable is deleted from the block palette while its blocks are still used in another sprite, the variable is not fully cleared. Instead, it is forced into a “for this sprite only” (local) variable.

**Steps to Reproduce:**

1. Create two sprites: Sprite1 and Sprite2.
2. In Sprite1, create a global variable (for all sprites). Place its "set to (0)“ or ”change by (1)“ block into the scripting area.
3. Switch to Sprite2. Right-click the variable in the block palette and select ”Delete the variable“.
4. Switch back to Sprite1.
5. Observe the block palette and the scripting area.

**Actual Result:**
The variable still exists in Sprite1, but its scope automatically changes to ”for this sprite only“. Furthermore, the rounded variable reporter block in the palette turns into a blank orange block with no name displayed.

### Issue 2: Monitor checkbox UI desync and duplicate monitors

When toggling the visibility checkboxes of built-in sprite reporters (like x position, y position, costume #, or size), the checkbox states do not synchronize correctly when switching between sprites and the Stage, allowing duplicate monitors to be added to the stage.

**Steps to Reproduce:**

1. Create two sprites: Sprite1 and Sprite2.
2. Select Sprite1, and check the monitor boxes for built-in reporters (e.g., x position, costume #, or size) to show them on the stage.
3. Click on the Stage (Backdrops).
4. Click on Sprite2. Notice that the checkboxes for these reporters are unchecked (which is normal since they are sprite-specific).
5. Click back on Sprite1.

**Actual Result:**

* Even though the monitors are visible on the stage, the checkboxes in Sprite1's palette incorrectly become unchecked.
* If you check those boxes in Sprite1 again, duplicate monitors are added to the stage (e.g., another ”Sprite1: x position“ appears).

**How to Temporary Reset / Clear the Duplicate Monitors:**
6. Immediately after Step 5, switch to Sprite2. The checkboxes here are now automatically checked. Uncheck them.
7. Click on the Stage (Backdrops).
8. Click back on Sprite2. The checkboxes are checked again. Unchecking them now will remove the duplicate monitors from the stage.

*Note: Even if you add more sprites, checking these boxes will always force the monitor to display as ”Sprite1: ", locking onto Sprite1.*

### Environment & Version Testing:

* **Scratch Desktop (Offline Editor) v3.32.1 & Latest Browser Version:** Both Issue 1 (forced local conversion / blank orange block) and Issue 2 (UI desync) are fully reproducible.
* **Scratch Desktop (Offline Editor) v3.29.1 (Older version):**
* For Issue 1, the deleted variable simply reappears as a global variable; it does not convert to a local variable or become a blank orange block.
* Issue 2 does not occur at all (functions normally).

This indicates that these behaviors were introduced in a relatively recent update. I hope this information helps the engineering team look into the issue. Thank you!
nembence
Scratcher
1000+ posts

Issues with variable scope conversion and monitor checkbox UI desync between sprites

My browser / operating system: Windows 10, Chrome 154, No Flash version detected

I can reproduce the bugs in the online editor, but for me in Issue 1, it seems to display the variable name correctly, even though the variable becomes local.

In Issue 2, it seems like the checkboxes connect to the monitors based on the sprite that was selected when the checkbox got added to the sidebar, instead of the sprite that is currently selected. After saving and reloading the project, the checkboxes seem to change their connections to the correct sprites.
With blocks that have a dropdown, the checkbox sometimes looks unchecked even if there is a monitor connected to it, but clicking on it twice can hide the monitor
Koneko_koko-2
Scratcher
100+ posts

Issues with variable scope conversion and monitor checkbox UI desync between sprites

It seems there might be a language-related issue as well.
I ran a series of tests with the language setting set to Japanese.
When I checked again with the language set to English, the variable names did not disappear.
nembence
Scratcher
1000+ posts

Issues with variable scope conversion and monitor checkbox UI desync between sprites

Koneko_koko-2 wrote:

It seems there might be a language-related issue as well.
I ran a series of tests with the language setting set to Japanese.
When I checked again with the language set to English, the variable names did not disappear.
I couldn't get the empty variable even when setting the language to Japanese.

It's also possible that that bug happens only in the offline editor, because there were some empty variable bugs with the “Spork” update that have been fixed since then
Koneko_koko-2
Scratcher
100+ posts

Issues with variable scope conversion and monitor checkbox UI desync between sprites

I checked it again. I was able to verify the text display using a procedure that isn’t language-dependent.
1. Create a variable and place a circular block.
2. Uncheck the “Display” box.
3. Move to a different sprite, check the box, and delete it.
4. When I returned to the original sprite, the variable’s name had not disappeared.

Additionally, when I placed only the circular block and deleted the variable without placing a “set to” block, the variable was deleted correctly—it did not become a local variable and did not remain in the palette.
Conversely, I found that when a variable had become a local variable, it disappeared from the palette after switching sprites and returning to the original one.
There may still be some other unusual behaviors.

Powered by DjangoBB