Skip to content

Commit e26b568

Browse files
committed
cleanup ellipsize logic from claude review
1 parent 2e15d03 commit e26b568

4 files changed

Lines changed: 2 additions & 52 deletions

File tree

extension/src/popup/components/TruncatedMemo/__tests__/TruncatedMemo.test.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ describe("TruncatedMemo", () => {
1919
expect(el.hasAttribute("title")).toBe(false);
2020
});
2121

22-
it("uses custom fallback when provided", () => {
23-
render(<TruncatedMemo memo={null} fallback="—" data-testid="memo" />);
24-
expect(screen.getByTestId("memo").textContent).toBe("—");
25-
});
26-
2722
it("does not mutate the memo (no trimming)", () => {
2823
const memo = " whitespace padded memo ";
2924
render(<TruncatedMemo memo={memo} data-testid="memo" />);
@@ -38,23 +33,4 @@ describe("TruncatedMemo", () => {
3833
expect(el.tagName).toBe("SPAN");
3934
expect(el.className).toContain("TruncatedMemo--inline");
4035
});
41-
42-
it("applies maxChars pre-truncation while preserving the full value in title", () => {
43-
const memo = "abcdefghijklmnop";
44-
render(<TruncatedMemo memo={memo} maxChars={6} data-testid="memo" />);
45-
const el = screen.getByTestId("memo");
46-
expect(el.textContent).toBe("abcdef…");
47-
expect(el.getAttribute("title")).toBe(memo);
48-
});
49-
50-
it("does not apply maxChars when memo fits within the limit", () => {
51-
render(<TruncatedMemo memo="short" maxChars={10} data-testid="memo" />);
52-
expect(screen.getByTestId("memo").textContent).toBe("short");
53-
});
54-
55-
it("treats maxChars={0} as no truncation", () => {
56-
const memo = "abcdef";
57-
render(<TruncatedMemo memo={memo} maxChars={0} data-testid="memo" />);
58-
expect(screen.getByTestId("memo").textContent).toBe(memo);
59-
});
6036
});

extension/src/popup/components/TruncatedMemo/index.tsx

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,21 @@ import "./styles.scss";
55

66
interface TruncatedMemoProps {
77
memo?: string | null;
8-
fallback?: string;
98
inline?: boolean;
10-
/**
11-
* Optional character limit. When set, memos longer than `maxChars` are
12-
* pre-truncated with an ellipsis before being handed to CSS. Useful in
13-
* tight popup layouts where the value cell shares its row with a fixed
14-
* suffix (e.g. a memo-type tag) and CSS-only ellipsis would still let
15-
* the value push past its share.
16-
*/
17-
maxChars?: number;
189
className?: string;
1910
"data-testid"?: string;
2011
}
2112

22-
const ellipsize = (value: string, maxChars: number) =>
23-
value.length > maxChars ? `${value.slice(0, maxChars).trimEnd()}…` : value;
24-
2513
export const TruncatedMemo = ({
2614
memo,
27-
fallback,
2815
inline = false,
29-
maxChars,
3016
className,
3117
"data-testid": dataTestId,
3218
}: TruncatedMemoProps) => {
3319
const { t } = useTranslation();
3420
const hasMemo = !!memo;
3521
const fullMemo = hasMemo ? (memo as string) : "";
36-
const fallbackText = fallback ?? t("None");
37-
const shouldEllipsize =
38-
hasMemo && typeof maxChars === "number" && maxChars > 0;
39-
const displayValue = hasMemo
40-
? shouldEllipsize
41-
? ellipsize(fullMemo, maxChars as number)
42-
: fullMemo
43-
: fallbackText;
22+
const displayValue = hasMemo ? fullMemo : t("None");
4423
const Tag = inline ? "span" : "div";
4524
const classes = [
4625
"TruncatedMemo",

extension/src/popup/components/accountHistory/TransactionDetail/styles.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,14 @@
299299
}
300300

301301
&__memo {
302-
// Truncation (overflow/ellipsis/nowrap) is owned by `.TruncatedMemo`;
303-
// this selector only adds the layout-specific tweaks needed in this
304-
// metadata row.
305302
width: 100%;
306-
text-align: right;
307303
}
308304

309305
&__value {
310306
&--memo {
311307
min-width: 0;
312308
flex: 1 1 0;
313309
max-width: 60%;
314-
overflow: hidden;
315310
text-align: right;
316311
}
317312

extension/src/popup/views/SignTransaction/Preview/Summary/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
&__value {
2626
color: var(
2727
--sds-clr-gray-12
28-
) !important; //sds rule does not allow changing colors on p tags
28+
) !important; //needed to override SDS color rules
2929

3030
&--memo {
3131
display: inline-flex;

0 commit comments

Comments
 (0)