Existing emoji tags appear as new in the composer; new emoji tags disappear after posting

AI-generated summary

scavin reported a bug where emoji tags behave inconsistently in the topic composer on unmodified main. When searching for an existing emoji tag (e.g., 😊), the dropdown may incorrectly show a Create option instead of the existing tag, particularly if the tag is outside the popular results limit. However, selecting Create still correctly attaches the existing tag. Conversely, when creating a genuinely new emoji tag, it can be selected in the composer but disappears after posting.

The root cause was identified in DiscourseTagging.clean_tag, which strips emoji characters from both search terms and new tag names. This causes the search to fall back to popular results (missing the emoji tag) and the save process to fail for new tags because the cleaned name no longer matches the original input.

Scavin proposed a patch that preserves complete emoji graphemes using Emoji.unicode_replacements data while maintaining ASCII filtering for non-emoji text. The fix also adjusts matching logic to allow disabled-tag suggestions to match emoji-leading names (e.g., 😊-restricted). The patch modifies two implementation files and adds regression tests in three test files, requiring no database migration or frontend changes. Local validation passed 572 backend and 8 browser tests, confirming that existing emoji tags display their usage count and that both existing and new emoji tags persist after publishing.

Update: The fix has been submitted as PR #44994: FIX: Preserve emoji tags during search and saving. Full CI, linting, and license checks passed on the author’s fork, although upstream CI still awaits maintainer approval for merging. The patch addresses the specific composer search and saving failures described but does not resolve all historical emoji-tag limitations referenced in related reports.

I found inconsistent behavior with emoji tags in the topic composer and reproduced it on unmodified main at 802125b979b5bb848a7cfc52409ef3176ffd4d82.

For an existing emoji tag, typing its name can show Create instead of the existing tag and its usage count. Selecting that option and posting still attaches the existing tag. A genuinely new emoji tag is a separate case: it can be selected in the composer, but disappears after posting.

To reproduce the existing-tag issue:

  1. Use a site with an existing emoji tag, such as 😊, and other, more frequently used tags.
  2. Open the topic composer and enter the emoji tag name.
  3. If that tag is outside the returned popular-tag limit, the dropdown shows a creation option and unrelated popular tags, without the existing tag’s usage count.
  4. Select the creation option, publish, and refresh. The topic still uses the original tag record.

In an isolated browser test, I used an existing emoji tag with a count of 17, an unrelated tag with a count of 100, and a search limit of 1. The dropdown showed Create: '😊' and popular x100; after posting, the existing emoji tag was correctly reused. With no existing 😊 record, the same operation returned HTTP 200 but saved no tag.

The cause is in DiscourseTagging.clean_tag, which is used for both search terms and saving new names. It removes emoji characters. Search then falls back to popular results, while saving can still find an existing tag by its original name before cleaning new names.

I have a small patch that preserves complete emoji graphemes recognized by the existing Emoji.unicode_replacements data. It keeps the existing ASCII filtering and removes invalid characters from non-emoji text. It also lets disabled-tag suggestions match the start of a name, since the current word-boundary expression misses emoji-leading names such as 😊-restricted.

The patch changes two implementation files and adds regression coverage in three test files. It does not add a database migration, frontend changes, a new API, or another emoji cache.

Local validation: 572 related backend examples and 8 browser examples passed. The browser tests check that an existing emoji tag shows x17, and that both it and a genuinely new 😊 remain after publishing and refreshing.

Update β€” October 23, 2026

The fix is now submitted as PR #44994: FIX: Preserve emoji tags during search and saving and is ready for review.

Full CI on my fork has passed: all 10 test matrix jobs, linting, and license checks.

For this run, I used a separate validation branch with the same fix and increased the test job timeout from 20/30 minutes to 90 minutes, since the earlier run timed out on the fork runner. The test commands, matrix, and assertions were unchanged. The timeout adjustment is not part of the upstream PR. The PR has not been merged; upstream CI still awaits maintainer approval.

Patch branch:

Related reports and discussion:

These reports describe earlier emoji-tag limitations. This patch addresses the composer search and saving failures reproduced above; it does not claim to resolve every emoji-tag issue.