mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
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:
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as browserEvents from '../browser_events.js';
|
import * as browserEvents from '../browser_events.js';
|
||||||
|
import {getFocusManager} from '../focus_manager.js';
|
||||||
import * as touch from '../touch.js';
|
import * as touch from '../touch.js';
|
||||||
import * as dom from '../utils/dom.js';
|
import * as dom from '../utils/dom.js';
|
||||||
import {Svg} from '../utils/svg.js';
|
import {Svg} from '../utils/svg.js';
|
||||||
@@ -98,5 +99,6 @@ export class DeleteCommentBarButton extends CommentBarButton {
|
|||||||
|
|
||||||
this.getParentComment().dispose();
|
this.getParentComment().dispose();
|
||||||
e?.stopPropagation();
|
e?.stopPropagation();
|
||||||
|
getFocusManager().focusNode(this.workspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {assert} from '../../node_modules/chai/chai.js';
|
||||||
import {
|
import {
|
||||||
assertEventFired,
|
assertEventFired,
|
||||||
createChangeListenerSpy,
|
createChangeListenerSpy,
|
||||||
@@ -167,5 +168,15 @@ suite('Workspace comment', function () {
|
|||||||
this.workspace.id,
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user