Skip to content

fix: replace line-clamp with custom logic in app card#23660

Closed
bandhan-majumder wants to merge 7 commits intocalcom:mainfrom
bandhan-majumder:fix-truncated-description
Closed

fix: replace line-clamp with custom logic in app card#23660
bandhan-majumder wants to merge 7 commits intocalcom:mainfrom
bandhan-majumder:fix-truncated-description

Conversation

@bandhan-majumder
Copy link
Contributor

What does this PR do?

Replaces line-clamp property with custom truncate logic as line-clamp is not supported properly by widely used browsers. More about it: https://developer.mozilla.org/en-US/docs/Web/CSS/line-clamp

Image Demo (if applicable):

first

image

second

image

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

@vercel
Copy link

vercel bot commented Sep 7, 2025

@bandhan-majumder is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Sep 7, 2025
@graphite-app graphite-app bot requested a review from a team September 7, 2025 19:31
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 7, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds an internal helper truncateText(text, maxLength = 130) inside packages/features/apps/components/AppCard.tsx that truncates long descriptions by character count, preserving word boundaries (uses last whitespace before the limit or the substring if none) and appends an ellipsis when truncated. The component now renders {truncateText(app.description)} for the description and replaces the prior CSS 3-line clamp usage with a numeric WebkitLineClamp: 3. No exported/public interfaces were changed.

Assessment against linked issues

Objective Addressed Explanation
Properly truncate long app card descriptions without relying on CSS line-clamp [#23659, CAL-6379]

Assessment against linked issues: Out-of-scope changes

None found.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the 🐛 bug Something isn't working label Sep 7, 2025
@dosubot dosubot bot added the 🧹 Improvements Improvements to existing features. Mostly UX/UI label Sep 7, 2025
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)
packages/features/apps/components/AppCard.tsx (3)

89-95: Make truncation grapheme-safe and avoid mid-codepoint splits.

Substring on UTF-16 can split emoji/combined characters and some CJK. Also, keep word-boundary behavior. Minor perf: define outside component or memoize, but not blocking.

Consider this drop-in replacement:

-  const truncateText = (text: string, maxLength = 170): string => {
-    if (!text || text.length <= maxLength) return text;
-    const truncated = text.substring(0, maxLength);
-    const lastSpace = truncated.lastIndexOf(" ");
-    return `${lastSpace > 0 ? text.substring(0, lastSpace) : truncated}...`;
-  };
+  const truncateText = (text: string, maxLength = 170): string => {
+    if (!text) return "";
+    const clean = text.trim();
+    if (clean.length <= maxLength) return clean;
+    const cps = Array.from(clean); // grapheme-safe slice
+    const slice = cps.slice(0, maxLength + 1).join("");
+    const lastSpace = slice.lastIndexOf(" ");
+    const head = lastSpace > 0 ? slice.slice(0, lastSpace) : cps.slice(0, maxLength).join("");
+    return `${head}…`;
+  };

Please verify with samples: long CJK text, emoji + ZWJ sequences, and no-space strings (e.g., 200-char “A”). Want me to add a quick unit test for these cases?


127-127: Small UX boost: show full description on hover (non-blocking).

Adding a title preserves discoverability after truncation; dir helps RTL.

-      <p className="text-default mt-2 flex-grow text-sm">{truncateText(app.description)}</p>
+      <p className="text-default mt-2 flex-grow text-sm" title={app.description} dir="auto">
+        {truncateText(app.description)}
+      </p>

188-188: Localize literal “Template”.

Per guidelines, wrap user-facing strings with t().

-          <span className="bg-error rounded-md px-2 py-1 text-sm font-normal text-red-800">Template</span>
+          <span className="bg-error rounded-md px-2 py-1 text-sm font-normal text-red-800">{t("template")}</span>
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5375c65 and e12d667.

📒 Files selected for processing (1)
  • packages/features/apps/components/AppCard.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/features/apps/components/AppCard.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/apps/components/AppCard.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/features/apps/components/AppCard.tsx
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache

@github-actions github-actions bot added the ui area: UI, frontend, button, form, input label Sep 8, 2025
Copy link
Contributor

@kart1ka kart1ka left a comment

Choose a reason for hiding this comment

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

This does not work properly and causes other issues with the layout such as messing with the position of the Details and Install buttons. See the image attached.

image

@kart1ka kart1ka marked this pull request as draft September 8, 2025 05:33
@bandhan-majumder
Copy link
Contributor Author

sorry for that. fixed now
image

@bandhan-majumder bandhan-majumder marked this pull request as ready for review September 8, 2025 13:42
@github-actions github-actions bot added the Low priority Created by Linear-GitHub Sync label Sep 8, 2025
Copy link
Contributor

@kart1ka kart1ka left a comment

Choose a reason for hiding this comment

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

does not work for every app card. see the image attached.
image

@kart1ka kart1ka marked this pull request as draft September 8, 2025 16:10
@bandhan-majumder bandhan-majumder marked this pull request as ready for review September 18, 2025 06:16
@bandhan-majumder
Copy link
Contributor Author

@kart1ka
fixed (it was browser specific issue I think, i removed the webkit related styles, should work now)
Brave | Chrome view
image

Copy link
Contributor

@kart1ka kart1ka left a comment

Choose a reason for hiding this comment

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

There are still lots of issues here. Please see the video attached.

I don't think this solution works really well. Can you please fix things and do a thorough testing from your end?

https://cap.so/s/xv9vre8tb2xpmpa

@kart1ka kart1ka marked this pull request as draft September 19, 2025 04:10
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2025

This PR is being marked as stale due to inactivity.

@Anshumancanrock
Copy link
Contributor

@dhairyashiil Here is the video in both desktop and mobile view. It works fine imo.. please check

Recording.2025-12-11.195333.1.1.1.mp4

@anikdhabal
Copy link
Contributor

Fixed by this:- #26722

@anikdhabal anikdhabal closed this Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working community Created by Linear-GitHub Sync 🧹 Improvements Improvements to existing features. Mostly UX/UI Low priority Created by Linear-GitHub Sync size/S Stale ui area: UI, frontend, button, form, input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: line-clamp property does not truncate long texts properly in app card description

4 participants