-
Notifications
You must be signed in to change notification settings - Fork 27
Fix user avatar emoji handling #2613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughA changelog entry documents an emoji handling fix in the user avatar feature, while the corresponding UserAvatar component is refactored to use lodash for character extraction instead of direct indexing, replacing functional logic with a lodash utility function. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2613 +/- ##
==========================================
Coverage 96.75% 96.75%
Complexity 1816 1816
==========================================
Files 434 434
Lines 12483 12483
Branches 2078 2078
==========================================
Hits 12078 12078
Misses 405 405 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
resources/js/components/UserAvatar.vue (1)
39-47: Fix emoji character handling in avatar label generationThe current implementation using
_.split(string, "", 1)[0]operates at the UTF-16 code unit level, breaking multi-code-unit emojis (surrogate pairs). For example, an emoji like 👋 will produce a broken replacement character "�" instead of the emoji itself.Use the spread operator to properly handle code points:
const avatarLabel = computed(() => { if (!props.firstname || !props.lastname) { return ""; } return ( - _.split(props.firstname?.toUpperCase(), "", 1)[0] + - _.split(props.lastname?.toUpperCase(), "", 1)[0] + [...props.firstname.toUpperCase()][0] + + [...props.lastname.toUpperCase()][0] ); });Also remove the lodash import:
import { computed } from "vue"; -import _ from "lodash";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
CHANGELOG.md(2 hunks)resources/js/components/UserAvatar.vue(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Docker Build
|
|
||
| <script setup> | ||
| import { computed } from "vue"; | ||
| import _ from "lodash"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Unnecessary lodash dependency for this use case.
Adding lodash solely for the _.split function is heavyweight when JavaScript provides better native solutions for emoji handling.
🤖 Prompt for AI Agents
In resources/js/components/UserAvatar.vue around line 14, remove the unnecessary
import of lodash and replace any usage of _.split for deriving avatar characters
with native string handling: delete the import line and update calls to use
Array.from(...) or the spread operator ([...str]) to correctly iterate Unicode
code points (emoji) or String.prototype.split where simple character splitting
suffices; ensure tests/uses expect the new output shape and remove the lodash
dependency from package.json if no other usages remain.
PILOS
|
||||||||||||||||||||||||||||
| Project |
PILOS
|
| Branch Review |
fix-emoji-handling-user-avatar
|
| Run status |
|
| Run duration | 07m 23s |
| Commit |
|
| Committer | Samuel Weirich |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
608
|
| View all changes introduced in this branch ↗︎ | |
Type
Checklist
Changes
Other information
The code extracting the first char of the users first/lastname broke emojis.
Before

After

Thanks @tibroc for reporting this bug
Summary by CodeRabbit