Skip to content

Commit

Permalink
add an constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jsartisan committed Feb 18, 2025
1 parent b9a4589 commit 9d486cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { textInputStyles } from "../../Input";

import styles from "./styles.module.css";
import type { MultiSelectProps } from "./types";

interface MultiSelectValueProps {
excludeFromTabOrder?: boolean;
isDisabled?: boolean;
Expand All @@ -23,6 +24,8 @@ interface MultiSelectValueProps {
isInvalid?: boolean;
}

const MAX_ELLIPSIS_COUNT = 999;

const MultiSelectValue: React.FC<MultiSelectValueProps> = ({
excludeFromTabOrder,
isDisabled,
Expand Down Expand Up @@ -145,7 +148,9 @@ const MultiSelectValue: React.FC<MultiSelectValueProps> = ({
</Text>
))}
<Text className={styles.ellipsisText}>
{visibleItems < totalItems && <>...+{totalItems - visibleItems}</>}
{visibleItems < totalItems && (
<>...+{Math.min(totalItems - visibleItems, MAX_ELLIPSIS_COUNT)}</>
)}
</Text>
</span>
<span data-input-suffix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
min-width: 0;
}

/* we are resevering max for 7 characters which describes "...+999" text */
.ellipsisText {
max-width: 7ch;
}
Expand Down

0 comments on commit 9d486cb

Please sign in to comment.