Skip to content

Commit b0c260e

Browse files
committed
fix: Make IDs of comment bar buttons consistent
1 parent 9af3629 commit b0c260e

4 files changed

Lines changed: 26 additions & 16 deletions

File tree

packages/blockly/core/comments/collapse_comment_bar_button.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,24 @@ export class CollapseCommentBarButton extends CommentBarButton {
4141
* @param container An SVG group that this button should be a child of.
4242
*/
4343
constructor(
44-
protected readonly id: string,
45-
protected readonly workspace: WorkspaceSvg,
46-
protected readonly container: SVGGElement,
47-
protected readonly commentView: CommentView,
44+
id: string,
45+
workspace: WorkspaceSvg,
46+
container: SVGGElement,
47+
commentView: CommentView,
4848
) {
49-
super(id, workspace, container, commentView);
49+
super(
50+
`${id}${COMMENT_COLLAPSE_BAR_BUTTON_FOCUS_IDENTIFIER}`,
51+
workspace,
52+
container,
53+
commentView,
54+
);
5055

5156
this.icon = dom.createSvgElement(
5257
Svg.IMAGE,
5358
{
5459
'class': 'blocklyFoldoutIcon',
5560
'href': `${this.workspace.options.pathToMedia}foldout-icon.svg`,
56-
'id': `${this.id}${COMMENT_COLLAPSE_BAR_BUTTON_FOCUS_IDENTIFIER}`,
61+
'id': this.id,
5762
},
5863
this.container,
5964
);

packages/blockly/core/comments/comment_bar_button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export abstract class CommentBarButton implements IFocusableNode {
2828
* @param container An SVG group that this button should be a child of.
2929
*/
3030
constructor(
31-
protected readonly id: string,
31+
readonly id: string,
3232
protected readonly workspace: WorkspaceSvg,
3333
protected readonly container: SVGGElement,
3434
protected readonly commentView: CommentView,

packages/blockly/core/comments/delete_comment_bar_button.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,24 @@ export class DeleteCommentBarButton extends CommentBarButton {
4141
* @param container An SVG group that this button should be a child of.
4242
*/
4343
constructor(
44-
protected readonly id: string,
45-
protected readonly workspace: WorkspaceSvg,
46-
protected readonly container: SVGGElement,
47-
protected readonly commentView: CommentView,
44+
id: string,
45+
workspace: WorkspaceSvg,
46+
container: SVGGElement,
47+
commentView: CommentView,
4848
) {
49-
super(id, workspace, container, commentView);
49+
super(
50+
`${id}${COMMENT_DELETE_BAR_BUTTON_FOCUS_IDENTIFIER}`,
51+
workspace,
52+
container,
53+
commentView,
54+
);
5055

5156
this.icon = dom.createSvgElement(
5257
Svg.IMAGE,
5358
{
5459
'class': 'blocklyDeleteIcon',
5560
'href': `${this.workspace.options.pathToMedia}delete-icon.svg`,
56-
'id': `${this.id}${COMMENT_DELETE_BAR_BUTTON_FOCUS_IDENTIFIER}`,
61+
'id': this.id,
5762
},
5863
container,
5964
);

packages/blockly/core/workspace_svg.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ export class WorkspaceSvg
254254
* @param e The right-click event that triggered the context menu.
255255
*/
256256
configureContextMenu:
257-
((menuOptions: ContextMenuOption[], e: Event) => void) | null = null;
257+
| ((menuOptions: ContextMenuOption[], e: Event) => void)
258+
| null = null;
258259

259260
/**
260261
* A dummy wheel event listener used as a workaround for a Safari scrolling issue.
@@ -2977,8 +2978,7 @@ export class WorkspaceSvg
29772978
return (
29782979
comment.view
29792980
.getCommentBarButtons()
2980-
.find((button) => button.getFocusableElement().id.includes(id)) ??
2981-
null
2981+
.find((button) => button.id.includes(id)) ?? null
29822982
);
29832983
}
29842984
}

0 commit comments

Comments
 (0)