Skip to content

fix: truncation of titles to fix UI breaks - #1162

Merged
Mythie merged 9 commits into
documenso:mainfrom
rhit-daviscl:field-truncation
Jul 29, 2024
Merged

Mythie merged 9 commits into
documenso:mainfrom
rhit-daviscl:field-truncation

Conversation

@rhit-daviscl

@rhit-daviscl rhit-daviscl commented May 16, 2024 •

Copy link
Copy Markdown
Contributor

Description

This pull request introduces the addition of CSS properties which will allow for the display of long titles in most sections not already implemented. This enhancement allows users to see their full screen without breaking the UI for having a long input.

Example

Related Issue

Fixes #950

Changes Made

  • Added a truncate CSS field to most document views and *-field classes
  • Changed spans to div in in *-field classes to better truncate
  • Added a hover effect where it displays the truncated text if the mouse hovers over the truncated name (in many places)

Testing Performed

  • Tested by giving the User a long name and seeing if the UI displays it all for truncates it.
  • Tested by giving a document a long name and see if the UI displays it all for truncate it.

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes, if applicable.
  • I have followed the project's coding style guidelines.
  • I have addressed the code review feedback from the previous submission, if applicable.

Additional Notes

No additional notes.

Summary by CodeRabbit

  • New Features

    • Enhanced rendering of text in various components, improving readability and hover context with truncation support.
    • Improved layout and styling of document titles and user invitations in the signing process.
  • Bug Fixes

    • Addressed layout issues by ensuring text truncation in key components for better responsive design.
  • Documentation

    • Updated internal logic for determining the selected team in the header component.

@vercel

vercel Bot commented May 16, 2024 •

Copy link
Copy Markdown

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

Name Status Preview Comments Updated (UTC)
stg-docs ❌ Failed (Inspect) May 16, 2024 1:58am

@vercel

vercel Bot commented May 16, 2024

Copy link
Copy Markdown

@rhit-daviscl is attempting to deploy a commit to the Documenso Team Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the apps: web Issues related to the webapp label May 16, 2024
@coderabbitai

coderabbitai Bot commented May 16, 2024 •

Copy link
Copy Markdown
Contributor

Walkthrough

The recent changes improve the user interface of the application by enhancing text handling across various components. Key updates include adding truncation classes to elements to manage overflow text, modifying the structure of email displays for better layout, and improving the contextual information provided to users. These adjustments aim to create a cleaner and more user-friendly experience.

Changes

File Path Change Summary
apps/web/src/app/(dashboard)/documents/[id]/document-page-view-recent-activity.tsx Added title attribute and truncate class to improve text visibility and user experience.
apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx, apps/web/src/app/(dashboard)/documents/[id]/logs/document-logs-page-view.tsx Added truncate class to <div> elements for better text handling and layout.
apps/web/src/app/(signing)/sign/[token]/name-field.tsx, apps/web/src/app/(signing)/sign/[token]/signature-field.tsx Changed from <span> to <div> to wrap emails, potentially affecting layout and styling.
apps/web/src/app/(signing)/sign/[token]/signing-page-view.tsx Removed truncateTitle function and introduced direct document title usage, enhancing readability.
apps/web/src/components/(dashboard)/layout/header.tsx Updated logic to determine the selected team from the URL path for improved contextual display.
packages/ui/primitives/avatar.tsx, packages/ui/primitives/dialog.tsx Added truncate class to enhance text handling in AvatarWithText and DialogTitle components.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant Header
    participant DocumentView
    participant NameField
    participant SignatureField

    User->>Header: Navigate to document
    Header-->>App: Determine selected team
    App->>DocumentView: Render document with title
    DocumentView->>NameField: Display recipient's name
    DocumentView->>SignatureField: Display recipient's email
    Note right of SignatureField: Email is now in a <div> for layout
Loading

Assessment against linked issues

Objective Addressed Explanation
Add input validation to all input fields (#950) ❌ No validation for input field lengths has been implemented.

🐇 "In the fields where rabbits roam,
Truncating text makes a cozy home.
With emails wrapped in blocks so neat,
A seamless flow, oh what a treat!
User-friendly paths we now explore,
Hopping along, we can't ignore!" 🌼


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 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.

@Mythie

Mythie commented May 16, 2024

Copy link
Copy Markdown
Collaborator

Hey there, it looks like you haven't accepted our contributor license agreement yet. In order for us to accept your pull request we ask that you please fill out the CLA:

https://documen.so/cla

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0ff3844 and 5a228b9.

Files selected for processing (9)
  • apps/web/src/app/(dashboard)/documents/[id]/document-page-view-recent-activity.tsx (1 hunks)
  • apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx (1 hunks)
  • apps/web/src/app/(dashboard)/documents/[id]/logs/document-logs-page-view.tsx (1 hunks)
  • apps/web/src/app/(signing)/sign/[token]/name-field.tsx (1 hunks)
  • apps/web/src/app/(signing)/sign/[token]/signature-field.tsx (1 hunks)
  • apps/web/src/app/(signing)/sign/[token]/signing-page-view.tsx (2 hunks)
  • apps/web/src/components/(dashboard)/layout/header.tsx (3 hunks)
  • packages/ui/primitives/avatar.tsx (1 hunks)
  • packages/ui/primitives/dialog.tsx (1 hunks)
Files skipped from review due to trivial changes (2)
  • apps/web/src/app/(dashboard)/documents/[id]/logs/document-logs-page-view.tsx
  • apps/web/src/app/(signing)/sign/[token]/signature-field.tsx
Additional comments not posted (10)
packages/ui/primitives/avatar.tsx (1)

81-83: LGTM! Verify the truncation behavior.

The addition of the truncate class to the div element wrapping the text sections is correct. Ensure that the truncation behavior works as expected and does not introduce any layout issues.

To verify:

  1. Check if the text is truncated correctly when it exceeds the available width.
  2. Ensure that the hover effect displays the full text as intended.
apps/web/src/components/(dashboard)/layout/header.tsx (4)

45-46: LGTM! Verify the usePathname hook usage.

The addition of the usePathname hook is correct. Ensure that it correctly retrieves the current pathname.

To verify:

  1. Check if the pathname variable correctly reflects the current URL path.
  2. Ensure that the usePathname hook is used appropriately and does not introduce any issues.

47-53: LGTM! Verify the isPathTeamUrl function.

The isPathTeamUrl function correctly checks if the current pathname corresponds to a team URL format. Ensure that it works as intended.

To verify:

  1. Check if the function correctly identifies team URLs.
  2. Ensure that the logic inside the function is robust and handles edge cases.

55-55: LGTM! Verify the selectedTeam variable.

The selectedTeam variable is correctly set based on the current pathname. Ensure that it correctly identifies the selected team.

To verify:

  1. Check if the selectedTeam variable correctly reflects the selected team based on the URL.
  2. Ensure that the find method works as intended and handles cases where no team is selected.

76-79: LGTM! Verify the title attribute update.

The title attribute is correctly updated based on the selectedTeam variable. Ensure that it correctly displays the team name or user name.

To verify:

  1. Check if the title attribute correctly reflects the selected team name or user name.
  2. Ensure that the title attribute updates dynamically based on the selectedTeam variable.
packages/ui/primitives/dialog.tsx (1)

116-116: LGTM! Verify the truncation behavior.

The addition of the truncate class to the className property of the DialogTitle component is correct. Ensure that the truncation behavior works as expected and does not introduce any layout issues.

To verify:

  1. Check if the text is truncated correctly when it exceeds the available width.
  2. Ensure that the hover effect displays the full text as intended.
apps/web/src/app/(signing)/sign/[token]/signing-page-view.tsx (2)

53-53: LGTM!

The title rendering is simplified and the truncate class is correctly applied.


64-69: LGTM!

The user invitation message is clear and the conditional rendering for the recipient's role is correctly implemented.

apps/web/src/app/(signing)/sign/[token]/name-field.tsx (1)

181-181: Verify the impact of changing <span> to <div>.

Changing from <span> to <div> may affect the layout due to the difference between inline and block elements. Ensure that this change does not disrupt the UI.

apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx (1)

113-113: LGTM! The addition of the truncate class is appropriate.

The truncate class will help in handling text overflow and prevent UI breaks caused by lengthy titles.

Comment on lines +136 to +141
<p
className="text-muted-foreground dark:text-muted-foreground/70 flex-auto truncate py-0.5 text-xs leading-5"
title={`${formatDocumentAuditLogAction(auditLog, userId).prefix} ${
formatDocumentAuditLogAction(auditLog, userId).description
}`}
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ensure consistent usage of formatDocumentAuditLogAction.

The title attribute and the paragraph content both use formatDocumentAuditLogAction. Consider storing the result in a variable to avoid redundant calls.

const formattedAction = formatDocumentAuditLogAction(auditLog, userId);

<p
  className="text-muted-foreground dark:text-muted-foreground/70 flex-auto truncate py-0.5 text-xs leading-5"
  title={`${formattedAction.prefix} ${formattedAction.description}`}
>
  <span className="text-foreground font-medium">
    {formattedAction.prefix}
  </span>{' '}
  {formattedAction.description}
</p>

Comment on lines +57 to +61
<p
className="text-muted-foreground truncate"
title={document.User.name ? document.User.name : ''}
>
{document.User.name}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ensure proper handling of null or undefined values.

The conditional rendering of document.User.name should handle cases where document.User might be null or undefined.

- title={document.User.name ? document.User.name : ''}
+ title={document.User?.name ?? ''}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<p
className="text-muted-foreground truncate"
title={document.User.name ? document.User.name : ''}
>
{document.User.name}
<p
className="text-muted-foreground truncate"
title={document.User?.name ?? ''}
>
{document.User.name}

@Mythie
Mythie merged commit f31caaa into documenso:main Jul 29, 2024
@Mythie

Mythie commented Jul 29, 2024

Copy link
Copy Markdown
Collaborator

Thanks for the effort! 😄

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

Labels

apps: web Issues related to the webapp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add input validation to all input fields

3 participants