Skip to content

Commit 74930b1

Browse files
authored
Avoiding accessing undefined mentionValues (#26461)
The `window.config.mentionValues` might be undefined: ``` {{if or .Participants .Assignees .MentionableTeams}} mentionValues: ... {{end}} ```
1 parent 2fc0eb9 commit 74930b1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

web_src/js/features/tribute.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function makeCollections({mentions, emoji}) {
3131

3232
if (mentions) {
3333
collections.push({
34-
values: window.config.mentionValues,
34+
values: window.config.mentionValues ?? [],
3535
requireLeadingSpace: true,
3636
menuItemTemplate: (item) => {
3737
return `

web_src/js/utils/match.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function matchMention(queryText) {
3232

3333
// results is a map of weights, lower is better
3434
const results = new Map();
35-
for (const obj of window.config.mentionValues) {
35+
for (const obj of window.config.mentionValues ?? []) {
3636
const index = obj.key.toLowerCase().indexOf(query);
3737
if (index === -1) continue;
3838
const existing = results.get(obj);

0 commit comments

Comments
 (0)