fix: Replace Truncate.Deprecated with CSS-based truncation (#2374)

The Truncate element as it exists has a bug where it can end up in an infinite loop when truncating to a very small size on mobiles. This makes the course outline view unresponsive on mobile and can lead to a crash.

This replaces the Truncate element with some CSS.
This commit is contained in:
Kshitij Sobti
2025-08-15 07:42:07 +05:30
committed by GitHub
parent 25830a2130
commit 53e925e07a
3 changed files with 18 additions and 5 deletions

View File

@@ -5,11 +5,21 @@
.item-card-header__title-btn {
justify-content: flex-start;
padding: 0;
flex: 1 1 0%;
flex: 1 1 0;
height: 1.5rem;
margin-right: .25rem;
background: transparent;
color: var(--pgn-color-black);
.truncate-1-line {
-webkit-line-clamp: 1; /* stylelint-disable-line value-no-vendor-prefix */
line-clamp: 1;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box; /* stylelint-disable-line value-no-vendor-prefix */
min-width: 100px;
-webkit-box-orient: vertical; /* stylelint-disable-line value-no-vendor-prefix */
}
}
.item-card-button-icon {

View File

@@ -3,7 +3,6 @@ import {
Button,
OverlayTrigger,
Tooltip,
Truncate,
} from '@openedx/paragon';
import {
ArrowDropDown as ArrowDownIcon,
@@ -48,7 +47,9 @@ const TitleButton = ({
onClick={onTitleClick}
>
{prefixIcon}
<Truncate.Deprecated lines={1} className={`${namePrefix}-card-title mb-0`}>{title}</Truncate.Deprecated>
<span className="truncate-1-line">
{title}
</span>
</Button>
</OverlayTrigger>
);

View File

@@ -1,5 +1,5 @@
import { Link } from 'react-router-dom';
import { Button, Truncate } from '@openedx/paragon';
import { Button } from '@openedx/paragon';
interface TitleLinkProps {
title: string;
@@ -22,7 +22,9 @@ const TitleLink = ({
to={titleLink}
>
{prefixIcon}
<Truncate.Deprecated lines={1} className={`${namePrefix}-card-title mb-0`}>{title}</Truncate.Deprecated>
<span className="truncate-1-line">
{title}
</span>
</Button>
);