Skip to content
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

fix(user): avatar icon not shown in User component #3387

Merged
merged 6 commits into from
Jul 6, 2024
Merged

Conversation

wingkwong
Copy link
Member

@wingkwong wingkwong commented Jul 1, 2024

Closes #3369

📝 Description

If name is defined in User and icon is defined in avatarProps. The icon won't be rendered because name is passed to Avatar. Users need to set an extra name to undefined in avatarProps. name in User and that in Avatar should be considered different.

⛳️ Current behavior (updates)

image

🚀 New behavior

image

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

Summary by CodeRabbit

  • Bug Fixes

    • Removed the name property from avatar settings to streamline user avatar handling.
  • Tests

    • Updated user component tests to check for avatar icon and initials, ensuring proper avatar display.

@wingkwong wingkwong added this to the v2.4.3 milestone Jul 1, 2024
Copy link

linear bot commented Jul 1, 2024

Copy link

vercel bot commented Jul 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2024 1:34pm
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2024 1:34pm

Copy link

changeset-bot bot commented Jul 1, 2024

🦋 Changeset detected

Latest commit: 0608d44

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@nextui-org/user Patch
@nextui-org/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented Jul 1, 2024

Walkthrough

A patch for the @nextui-org/user package has been implemented to address an issue with the avatar icon visualization in the User component. The name property has been removed from avatarProps in the useUser function. Additionally, test files have been updated to reflect changes in the icon import path and validate the display of the avatar icon and initials.

Changes

File Summary
.changeset/real-falcons-care.md Summary of changes: Removal of name property from avatarProps in use-user.ts
packages/components/user/src/use-user.ts Adjusted avatarProps in useUser function: Removed name property assignment.
packages/components/user/__tests__/user.test.tsx Updated import path for AvatarIcon and modified tests to check avatar icon and initials.

Sequence Diagrams

No sequence diagrams are required for these changes as they primarily involve minor adjustments to property assignments and test updates without significant control flow alterations.

Assessment against linked issues

Objective Addressed Explanation
Ensure avatar icon displays correctly by utilizing icon property instead of name (Issue #3369)
Remove erroneous name attribute from avatarProps (Issue #3369)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9daef56 and 7b03382.

Files selected for processing (3)
  • .changeset/real-falcons-care.md (1 hunks)
  • packages/components/user/tests/user.test.tsx (3 hunks)
  • packages/components/user/src/use-user.ts (1 hunks)
Additional comments not posted (5)
.changeset/real-falcons-care.md (1)

1-5: Changeset note looks good.

The changeset accurately reflects the changes made in the PR, specifically the removal of the name property from avatarProps in use-user.ts.

packages/components/user/__tests__/user.test.tsx (3)

6-6: Import statement looks good.

The import statement for AvatarIcon is correctly added.


79-90: Test case for rendering avatar icon looks good.

The test case correctly verifies that the avatar icon is rendered when provided in avatarProps.


92-104: Test case for displaying initials in avatar looks good.

The test case correctly verifies that the initials are displayed in the avatar when both name and avatarProps with a name are provided.

packages/components/user/src/use-user.ts (1)

Line range hint 35-55: Ensure the removal of name from avatarProps does not affect functionality.

The removal of the name property from avatarProps looks good, but verify that this does not introduce any issues in the components using useUser.

Verification successful

The removal of the name property from avatarProps does not introduce any issues.

  • The search did not find any direct accesses to avatarProps.name in the relevant files, indicating that the property is not used directly.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the removal of `name` from `avatarProps` does not introduce any issues.

# Test: Search for the usage of `avatarProps` in the codebase. Expect: No issues due to the removal of `name`.
rg --type js --type ts 'avatarProps'

Length of output: 3158



Script:

#!/bin/bash
# Description: Ensure the removal of `name` from `avatarProps` does not introduce any issues by searching for direct accesses to `name` in relevant files.

# Search for direct accesses to the `name` property within `avatarProps` in the `useUser` function and related files.
rg --type js --type ts 'avatarProps\.name' packages/components/user/src/use-user.ts packages/components/user/src/user.tsx packages/components/user/__tests__/user.test.tsx

Length of output: 172

@jrgarciadev jrgarciadev merged commit c5ab49a into canary Jul 6, 2024
8 checks passed
@jrgarciadev jrgarciadev deleted the fix/eng-1075 branch July 6, 2024 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - avatar icon not shown in User component
2 participants