fix: Prevent loss of focus when deleting a workspace comment. (#9200)

* fix: Prevent loss of focus when deleting a workspace comment.

* chore: Add test verifying workspace comment focus behavior on deletion.
This commit is contained in:
Aaron Dodson
2025-07-08 13:50:26 -07:00
committed by GitHub
parent 8580d763b3
commit fc9164de8f
2 changed files with 13 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import {assert} from '../../node_modules/chai/chai.js';
import {
assertEventFired,
createChangeListenerSpy,
@@ -167,5 +168,15 @@ suite('Workspace comment', function () {
this.workspace.id,
);
});
test('focuses the workspace when deleted', function () {
const comment = new Blockly.comments.RenderedWorkspaceComment(
this.workspace,
);
Blockly.getFocusManager().focusNode(comment);
assert.equal(Blockly.getFocusManager().getFocusedNode(), comment);
comment.view.getCommentBarButtons()[1].performAction();
assert.equal(Blockly.getFocusManager().getFocusedNode(), this.workspace);
});
});
});