(
const {items} = props
- const getDisplayedName = useCallback(
- (name: string) => {
- // Heuristic value based on max display name and handle lengths
- const DISPLAY_LIMIT = 30
- if (name.length > DISPLAY_LIMIT) {
- const graphemes = splitter.splitGraphemes(name)
-
- if (graphemes.length > DISPLAY_LIMIT) {
- return graphemes.length > DISPLAY_LIMIT
- ? `${graphemes.slice(0, DISPLAY_LIMIT).join('')}...`
- : name.substring(0, DISPLAY_LIMIT)
- }
- }
-
- return name
- },
- [splitter],
- )
-
return (
{items.length > 0 ? (
items.map((item, index) => {
- const displayName = getDisplayedName(
+ const {name: displayName} = getGraphemeString(
item.displayName ?? item.handle,
+ 30, // Heuristic value; can be modified
)
const isSelected = selectedIndex === index
@@ -197,7 +177,7 @@ const MentionList = forwardRef(
- {item.handle}
+ @{item.handle}
)