feat: Beep when attempting constrained move on top-level block (#9635)

* feat: Beep when attempting constrained move on top-level block

* chore: Remove errant `only`

* refactor: Add and use `playErrorBeep()`
This commit is contained in:
Aaron Dodson
2026-03-18 12:45:01 -07:00
committed by GitHub
parent 83c8caca97
commit c862b5ef0e
3 changed files with 11 additions and 0 deletions
@@ -380,6 +380,7 @@ export class BlockDragStrategy implements IDragStrategy {
if (this.moveMode === MoveMode.CONSTRAINED) {
showUnconstrainedMoveHint(this.workspace, true);
this.workspace.getAudioManager().playErrorBeep();
}
}
}
+7
View File
@@ -138,6 +138,13 @@ export class WorkspaceAudio {
oscillator.stop(this.context.currentTime + duration);
}
/**
* Plays a standard error beep.
*/
async playErrorBeep() {
return this.beep(260);
}
/**
* Returns whether or not playing sounds is currently allowed.
*
@@ -534,6 +534,7 @@ suite('Keyboard-driven movement', function () {
suite('in constrained mode', function () {
test('prompts to use unconstrained mode when no destinations are available', function () {
const toastSpy = sinon.spy(Blockly.Toast, 'show');
const beepSpy = sinon.spy(this.workspace.getAudioManager(), 'beep');
Blockly.getFocusManager().focusNode(this.element);
const originalBounds = this.element.getBoundingRectangle();
startMove(this.workspace);
@@ -547,6 +548,8 @@ suite('Keyboard-driven movement', function () {
? 'Hold ⌘ Command and use arrow keys to move freely, then Enter to accept the position'
: 'Hold Ctrl and use arrow keys to move freely, then Enter to accept the position',
);
sinon.assert.calledOnce(beepSpy);
beepSpy.restore();
toastSpy.restore();
});