close
Skip to content

[2.x] fix(mentions): prevent crash when tag or group has no icon/color#4447

Merged
imorland merged 1 commit into2.xfrom
im/fix-tag-mention-null-icon
Mar 14, 2026
Merged

[2.x] fix(mentions): prevent crash when tag or group has no icon/color#4447
imorland merged 1 commit into2.xfrom
im/fix-tag-mention-null-icon

Conversation

@imorland
Copy link
Copy Markdown
Member

Summary

  • Fixes TypeError: Cannot read properties of null (reading 'toString') in the composer preview when mentioning a tag or group that has no icon/color set
  • In postFilterTagMentions and postFilterGroupMentions, model.icon() / group.icon() return JS null for tags without icons. The s9e TextFormatter JS serializer calls .toString() on every attribute value, crashing on null
  • Fix: coerce null to '' with || '' on all four nullable attributes (icon, color for both tags and groups)

Closes #4436

Test plan

  • Two new integration test cases in TagMentionsTest.php: one for a tag with icon, one for a tag without icon — asserts no crash and correct rendering
  • Manually create a tag with no icon set, mention it in a post composer, verify preview renders without error

Calling tag.setAttribute('icon', model.icon()) when model.icon() returns
null causes a TypeError in the s9e TextFormatter JS serializer, which
calls .toString() on every attribute value. Coerce null to '' to prevent
the crash.

Fixes #4436

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imorland imorland requested a review from a team as a code owner March 14, 2026 23:06
@imorland imorland changed the title fix(mentions): prevent crash when tag or group has no icon/color [2.x] fix(mentions): prevent crash when tag or group has no icon/color Mar 14, 2026
@imorland imorland added this to the 2.0.0-beta.8 milestone Mar 14, 2026
@imorland imorland merged commit f9202b1 into 2.x Mar 14, 2026
27 checks passed
@imorland imorland deleted the im/fix-tag-mention-null-icon branch March 14, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.x] JS Error when mentioning a tag without an icon

1 participant