Skip to content

Commit 7f5544c

Browse files
committed
fix: extract comment identifier to constant
1 parent eeae364 commit 7f5544c

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

core/comments/comment_editor.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import {Size} from '../utils/size.js';
1313
import {Svg} from '../utils/svg.js';
1414
import {WorkspaceSvg} from '../workspace_svg.js';
1515

16+
/**
17+
* String added to the ID of a workspace comment to identify
18+
* the focusable node for the comment editor.
19+
*/
20+
export const COMMENT_EDITOR_FOCUS_IDENTIFIER = '_comment_textarea_';
21+
1622
/** The part of a comment that can be typed into. */
1723
export class CommentEditor implements IFocusableNode {
1824
id?: string;
@@ -52,7 +58,7 @@ export class CommentEditor implements IFocusableNode {
5258
this.foreignObject.appendChild(body);
5359

5460
if (commentId) {
55-
this.id = commentId + '_comment_textarea_';
61+
this.id = commentId + COMMENT_EDITOR_FOCUS_IDENTIFIER;
5662
this.textArea.setAttribute('id', this.id);
5763
}
5864

core/workspace_svg.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type {Block} from './block.js';
2222
import type {BlockSvg} from './block_svg.js';
2323
import type {BlocklyOptions} from './blockly_options.js';
2424
import * as browserEvents from './browser_events.js';
25+
import {COMMENT_EDITOR_FOCUS_IDENTIFIER} from './comments/comment_editor.js';
2526
import {RenderedWorkspaceComment} from './comments/rendered_workspace_comment.js';
2627
import {WorkspaceComment} from './comments/workspace_comment.js';
2728
import * as common from './common.js';
@@ -2779,7 +2780,7 @@ export class WorkspaceSvg
27792780

27802781
// Search for a specific workspace comment editor
27812782
// (only if id seems like it is one).
2782-
const commentEditorIndicator = id.indexOf('_comment_textarea_');
2783+
const commentEditorIndicator = id.indexOf(COMMENT_EDITOR_FOCUS_IDENTIFIER);
27832784
if (commentEditorIndicator !== -1) {
27842785
const commentId = id.substring(0, commentEditorIndicator);
27852786
const comment = this.searchForWorkspaceComment(commentId);

0 commit comments

Comments
 (0)