Fix user avatar fallback initials display in RiskAssessmentFeed.tsx, … - #840
Conversation
…line 265 The risk assessment feed avatar fallback displayed only the first character of a user's name. Update it to show up to two initials instead.
There was a problem hiding this comment.
Thanks a lot for the quick PR! 🙏 The fix already goes in the right direction, but there's still a small bug: instead of the expected single initial (e.g. "J"), it currently shows "UU". See screenshot.
As you suggested correctly, the root cause isn't in the code changed here, but in findUser in src/utils/view.ts. There, realName is built via name.first + " " + name.last. Since traits.name can also be a plain string (and first/last are optional), this ends up as "undefined undefined" → initials "UU".
What do you think about also making these changes in view.ts? It reuses the existing getUserFullName helper, which handles both the string and the {first, last} case (same as in UserNav.tsx):
import { type Identity } from "@ory/client-fetch";
+import { getUserFullName, type User } from "@/types/auth";
import { externalProviderIdToIntegrationName } from "./externalProvider"; if (currentUser?.id === id) {
+ const fullName = getUserFullName(currentUser as unknown as User);
return {
displayName: "You",
avatarUrl: currentUser.traits?.picture,
- realName:
- currentUser.traits?.name.first + " " + currentUser.traits?.name.last,
+ realName: fullName || currentUser.traits?.email || "You",
};
}If you're happy with this, feel free to commit it and I'll approve the PR :)
|
got it, thanks. i will implement it and update the PR. |
…emove the getting two initals of first and last name and changed to get only one intial like asked, i test the comments and now appear the real inital i tested with few accounts not one.
|
thanks for your review and approving, bye and good luck in your stuff |

Fixed RiskAssessmentFeed default Icon is an "U" but should be user initals
l3montree-dev/devguard#2653
The issue was that the avatar fallback only used user.realName.charAt(0), so users without an avatar only showed one letter. Changed it to generate initials from the user name by taking the first letter of up to two name parts and converting them to uppercase.
While checking the issue I also looked into the findUser helper. It can return "Unknown" when the user ID from the event does not match any organization member or current user. I did not change this logic because I could not confirm this was the cause without a working backend/Ory environment, but it may be related to cases where the wrong user data is received.the file name is view.ts
I could not fully test the application locally because the frontend requires the backend and Ory services to run. The change was tested by checking the frontend code path and formatting/linting requirements. if need more detials ask.