GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: avoid clearing the state of the sensing_of block by refreshing t… · scratchfoundation/scratch-gui@9bd036b

This repository was archived by the owner on Jun 10, 2026. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/containers
    • blocks.jsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/containers/blocks.jsx‎

Copy file name to clipboardExpand all lines: src/containers/blocks.jsx
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ class Blocks extends React.Component {
145145
"PROCEDURE",
146146
this.ScratchBlocks.ScratchProcedures.getProceduresCategory
147147
);
148-
this.workspace.addChangeListener((event) => {
148+
149+
this.toolboxUpdateChangeListener = (event) => {
149150
if (
150151
event.type === this.ScratchBlocks.Events.VAR_CREATE ||
151152
event.type === this.ScratchBlocks.Events.VAR_RENAME ||
@@ -161,7 +162,8 @@ class Blocks extends React.Component {
161162
) {
162163
this.requestToolboxUpdate();
163164
}
164-
});
165+
};
166+
this.workspace.addChangeListener(this.toolboxUpdateChangeListener);
165167

166168
// Register buttons under new callback keys for creating variables,
167169
// lists, and procedures from extensions.
@@ -515,6 +517,7 @@ class Blocks extends React.Component {
515517

516518
// Remove and reattach the workspace listener (but allow flyout events)
517519
this.workspace.removeChangeListener(this.props.vm.blockListener);
520+
this.workspace.removeChangeListener(this.toolboxUpdateChangeListener);
518521
const dom = this.ScratchBlocks.utils.xml.textToDom(data.xml);
519522
try {
520523
this.ScratchBlocks.Xml.clearWorkspaceAndLoadFromXml(
@@ -556,6 +559,15 @@ class Blocks extends React.Component {
556559
// fresh workspace and we don't want any changes made to another sprites
557560
// workspace to be 'undone' here.
558561
this.workspace.clearUndo();
562+
// Let events get flushed before readding the toolbox-updater listener
563+
// to avoid unneeded refreshes.
564+
requestAnimationFrame(() => {
565+
setTimeout(() => {
566+
this.workspace.addChangeListener(
567+
this.toolboxUpdateChangeListener
568+
);
569+
});
570+
});
559571
}
560572
handleMonitorsUpdate(monitors) {
561573
// Update the checkboxes of the relevant monitors.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.