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

FIXED: Text overflows in the user management card details #9532 #9541

Conversation

piyushyadav0191
Copy link

@piyushyadav0191 piyushyadav0191 commented Dec 23, 2024

Proposed Changes

  • Fixes Text is overlapping on the user management page #9532
  • Added responsive max-width constraints for different screen sizes (sm/md/lg)
  • Improved text truncation with proper ellipsis for long names
  • Added tooltips to show full text on hover
  • Fixed mobile layout with proper wrapping

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • [] Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • New Features

    • Introduced tooltip functionality for enhanced user interaction in the user list and card display.
    • User's name now features tooltips that provide additional information on hover.
  • Style

    • Adjusted layout for improved spacing and alignment of user information.

@piyushyadav0191 piyushyadav0191 requested a review from a team as a code owner December 23, 2024 14:24
Copy link
Contributor

coderabbitai bot commented Dec 23, 2024

Walkthrough

The pull request enhances the UserListAndCard.tsx component by introducing tooltip functionality for user names. By importing tooltip-related components from the UI library, the changes wrap user information in tooltips that provide additional context when users hover over names. This modification aims to improve the user interface's readability and information presentation, particularly addressing potential text overflow and overlapping issues on different screen sizes.

Changes

File Change Summary
src/components/Users/UserListAndCard.tsx - Added imports for Tooltip, TooltipContent, TooltipProvider, TooltipTrigger
- Modified getNameAndStatusCard function to wrap user name in tooltip components
- Adjusted layout to manage width and overflow behavior

Assessment against linked issues

Objective Addressed Explanation
Prevent text overlapping on mobile screens [#9532]
Ensure text fits within container without overflow [#9532]

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 Tooltips dancing, text no more cramped,
Hover and reveal, information stamped!
Mobile screens rejoice, no overlap in sight,
User cards now shine, clean and bright!
A rabbit's UI magic, smooth and light! 🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88b3914 and 968eba3.

📒 Files selected for processing (1)
  • src/components/Users/UserListAndCard.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Users/UserListAndCard.tsx

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

netlify bot commented Dec 23, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 968eba3
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6770dc381fda1600085f5ca3
😎 Deploy Preview https://deploy-preview-9541--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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

🧹 Nitpick comments (3)
src/components/Users/UserListAndCard.tsx (3)

8-13: Add a short docstring for the new imports.
These imports introduce new UI components for tooltips. Although the usage is clear, adding a short comment or docstring on top of this import block to explain their purpose can help future maintainers quickly identify where tooltips are sourced.


92-106: Create a reusable tooltip wrapper component to reduce duplication.
The tooltip structure for displaying the user’s name appears again for the username block. Consider extracting these repetitive sections into a small wrapper component that accepts the text as a prop, which will make the usage more concise and maintainable.


139-139: Optional: Provide accessibility text for the details button.
You might consider adding an aria-label to the button for better screen reader support, especially if the text is truncated on smaller screens.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 79e098e and 03161e0.

📒 Files selected for processing (1)
  • src/components/Users/UserListAndCard.tsx (2 hunks)
🔇 Additional comments (1)
src/components/Users/UserListAndCard.tsx (1)

120-135: Ensure consistent styling and naming in the tooltip.
Currently, the approach is consistent with the user’s name tooltip. Please confirm that the styling (e.g., font size, whitespace, max-width) matches the user’s name tooltip to provide a uniform user experience. Additionally, consider i18n or a fallback string if the username is not available.

✅ Verification successful

Let me search for similar tooltip implementations and styling patterns in the codebase to verify the consistency.


Let me try one more search to find all tooltip implementations in the file to compare styling:


Styling is consistent with other tooltips in the component.

Based on the code review, the username tooltip implementation follows the same pattern as the user's name tooltip:

  • Both use the same TooltipProvider with delayDuration={200}
  • Both have the same max-w-sm break-words styling for the tooltip content
  • Both handle text overflow consistently with text-ellipsis overflow-hidden whitespace-nowrap
  • Both are wrapped in the same container with responsive max-width constraints
  • Fallback for username is handled via the optional chaining (??) in the Avatar component
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for similar tooltip implementations
rg -U "TooltipProvider.*TooltipTrigger.*TooltipContent" -A 5

Length of output: 62


Script:

#!/bin/bash
# Search for username-related tooltips specifically
rg -U "username.*Tooltip" -A 5

Length of output: 32


Script:

#!/bin/bash
# Look for i18n implementations with usernames
rg "user\.username" -A 2 -B 2

Length of output: 5628


Script:

#!/bin/bash
# Search for any fallback handling with usernames
ast-grep --pattern 'user.username || $_'

Length of output: 42


Script:

#!/bin/bash
# Search for all tooltips in the UserListAndCard.tsx file
cat src/components/Users/UserListAndCard.tsx

Length of output: 14305

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

let's only do for name and not username. username already has validations to disallow long usernames

@piyushyadav0191
Copy link
Author

Okay, let me take care of it.

@piyushyadav0191
Copy link
Author

@rithviknishad Fixed what you asked for

@github-actions github-actions bot added needs-triage question Further information is requested labels Dec 23, 2024
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: 1

🔭 Outside diff range comments (1)
src/components/Users/UserListAndCard.tsx (1)

Line range hint 293-307: Apply consistent overflow handling to list view

The text overflow handling and tooltip implementation should be consistent across both card and list views.

Apply the same overflow handling and tooltip implementation to the name and username in the list view:

 <div className="flex flex-col">
-  <h1 id={`name-${user.username}`} className="text-sm font-medium">
-    {formatName(user)}
-  </h1>
-  <span
-    id={`username-${user.username}`}
-    className="text-xs text-gray-500"
-  >
-    @{user.username}
-  </span>
+  <div className="min-w-0 max-w-[200px]">
+    <TooltipProvider delayDuration={200}>
+      <Tooltip>
+        <TooltipTrigger asChild aria-label={`Full name: ${formatName(user)}`}>
+          <h1 id={`name-${user.username}`} className="text-sm font-medium text-ellipsis overflow-hidden whitespace-nowrap">
+            {formatName(user)}
+          </h1>
+        </TooltipTrigger>
+        <TooltipContent role="tooltip">
+          <p className="max-w-sm break-words">{formatName(user)}</p>
+        </TooltipContent>
+      </Tooltip>
+    </TooltipProvider>
+  </div>
+  <div className="min-w-0 max-w-[200px]">
+    <TooltipProvider delayDuration={200}>
+      <Tooltip>
+        <TooltipTrigger asChild aria-label={`Username: ${user.username}`}>
+          <span
+            id={`username-${user.username}`}
+            className="text-xs text-gray-500 block text-ellipsis overflow-hidden whitespace-nowrap"
+          >
+            @{user.username}
+          </span>
+        </TooltipTrigger>
+        <TooltipContent role="tooltip">
+          <p className="max-w-sm break-words">@{user.username}</p>
+        </TooltipContent>
+      </Tooltip>
+    </TooltipProvider>
+  </div>
 </div>
🧹 Nitpick comments (1)
src/components/Users/UserListAndCard.tsx (1)

91-106: Enhance tooltip accessibility while maintaining the overflow fix

The implementation effectively addresses text overflow using responsive max-width constraints and proper text truncation. However, let's enhance the tooltip accessibility.

Consider these accessibility improvements:

 <TooltipProvider delayDuration={200}>
   <Tooltip>
-    <TooltipTrigger asChild>
+    <TooltipTrigger asChild aria-label={`Full name: ${formatName(user)}`}>
       <h1
         id={`name-${user.username}`}
         className="text-base font-bold text-ellipsis overflow-hidden whitespace-nowrap"
       >
         {formatName(user)}
       </h1>
     </TooltipTrigger>
-    <TooltipContent>
+    <TooltipContent role="tooltip">
       <p className="max-w-sm break-words">{formatName(user)}</p>
     </TooltipContent>
   </Tooltip>
 </TooltipProvider>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03161e0 and ef780bd.

📒 Files selected for processing (1)
  • src/components/Users/UserListAndCard.tsx (2 hunks)
🔇 Additional comments (1)
src/components/Users/UserListAndCard.tsx (1)

8-13: LGTM: Clean tooltip component imports

The tooltip-related imports are properly organized and follow the project's import structure.

Comment on lines 119 to 126
<div className="min-w-0 max-w-full sm:max-w-[200px] md:max-w-[300px] lg:max-w-[400px]">
<span
className="text-sm text-gray-500 block text-ellipsis overflow-hidden whitespace-nowrap"
id={`username-${user.username}`}
>
{user.username}
</span>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add tooltip for username consistency

While the username display properly handles overflow, it should have the same tooltip functionality as the name display for consistency.

Add tooltip wrapper for username:

 <div className="min-w-0 max-w-full sm:max-w-[200px] md:max-w-[300px] lg:max-w-[400px]">
+  <TooltipProvider delayDuration={200}>
+    <Tooltip>
+      <TooltipTrigger asChild aria-label={`Username: ${user.username}`}>
         <span
           className="text-sm text-gray-500 block text-ellipsis overflow-hidden whitespace-nowrap"
           id={`username-${user.username}`}
         >
           {user.username}
         </span>
+      </TooltipTrigger>
+      <TooltipContent role="tooltip">
+        <p className="max-w-sm break-words">{user.username}</p>
+      </TooltipContent>
+    </Tooltip>
+  </TooltipProvider>
 </div>

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 119 to 126
<div className="min-w-0 max-w-full sm:max-w-[200px] md:max-w-[300px] lg:max-w-[400px]">
<span
className="text-sm text-gray-500 block text-ellipsis overflow-hidden whitespace-nowrap"
id={`username-${user.username}`}
>
{user.username}
</span>
</div>
Copy link
Member

Choose a reason for hiding this comment

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

do revert all changes to the username. there are still some changes

Copy link
Author

Choose a reason for hiding this comment

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

You mean I should revert all changes to username means username inside that tooltip or the original code?

Copy link
Member

Choose a reason for hiding this comment

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

keep original code

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I will just use original code and add tooltip to name only as other maintainer suggested

@rithviknishad rithviknishad added changes required and removed question Further information is requested needs-triage labels Dec 23, 2024
@piyushyadav0191
Copy link
Author

@rithviknishad created PR of what you asked for

@github-actions github-actions bot added needs-triage question Further information is requested labels Dec 24, 2024
@@ -93,7 +93,7 @@ const getNameAndStatusCard = (
<TooltipTrigger asChild>
<h1
id={`name-${user.username}`}
className="text-base font-bold"
className="text-base font-bold truncate max-w-[200px]"
Copy link
Member

Choose a reason for hiding this comment

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

use rem values over pixels. pixels can behave differently on different DPIs

Copy link
Author

Choose a reason for hiding this comment

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

done

@rithviknishad
Copy link
Member

image

@piyushyadav0191
Copy link
Author

@rithviknishad if there is no extra changes required !!Can you merge the PR?

@github-actions github-actions bot added needs-triage question Further information is requested labels Dec 26, 2024
@rithviknishad rithviknishad added needs review and removed question Further information is requested changes required needs-triage labels Dec 26, 2024
{formatName(user)}
</h1>
</TooltipTrigger>
<TooltipContent>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest a bit more styling to the tooltip content. Check the tooltip for Occupancy Badge in Facility for instance:

image

Copy link
Author

@piyushyadav0191 piyushyadav0191 Dec 27, 2024

Choose a reason for hiding this comment

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

Okay, I just added more styling and dynamic transitions on state and side. @Jacobjeevan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text is overlapping on the user management page
3 participants