Skip to content

Commit cc693a4

Browse files
fix: prevent block duplication when typing in input fields (#4788)
1 parent 74b88f5 commit cc693a4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

js/activity.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
*/
4949
const LEADING = 0;
5050
const BLOCKSCALES = [1, 1.5, 2, 3, 4];
51-
const _THIS_IS_MUSIC_BLOCKS_ = true;
51+
const _THIS_IS_MUSIC_BLOCKS_ = true;oninput
5252
const _THIS_IS_TURTLE_BLOCKS_ = !_THIS_IS_MUSIC_BLOCKS_;
5353

5454
const _ERRORMSGTIMEOUT_ = 15000;
@@ -538,6 +538,17 @@ class Activity {
538538
false
539539
);
540540
};
541+
/*
542+
* Prevents workspace duplication or glitches when typing inside input boxes
543+
* Fix for Issue #4788
544+
*/
545+
window.addEventListener("keydown", function (event) {
546+
// If the active element is an input field (like Set Pen Size)
547+
if (event.target && event.target.tagName === "INPUT") {
548+
event.stopPropagation();
549+
return; // Don't trigger workspace keyboard events
550+
}
551+
});
541552

542553
/*
543554
* displays helpfulWheel on canvas on right click

0 commit comments

Comments
 (0)