Skip to content

Commit

Permalink
custom MultiValue component to show short label of multi value
Browse files Browse the repository at this point in the history
  • Loading branch information
roienatan committed Dec 11, 2023
1 parent 4500a0f commit 6880c8a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FC, ReactElement, useEffect, useState } from "react";
import { useDispatch } from "react-redux";
import Select from "react-select";
import Select, { components } from "react-select";
import { Modal, UserAvatar } from "@/shared/components";
import { useDMUserChatChannel } from "@/shared/hooks/useCases";
import useThemeColor from "@/shared/hooks/useThemeColor";
Expand All @@ -23,6 +23,7 @@ interface DirectMessageModalProps {
interface SelectOption {
value: string;
label: JSX.Element;
shortLabel: string;
uid: string;
}

Expand Down Expand Up @@ -102,6 +103,7 @@ const DirectMessageModal: FC<DirectMessageModalProps> = (props) => {
<span>{user.userName}</span>
</div>
),
shortLabel: user.userName,
uid: user.uid,
}));

Expand Down Expand Up @@ -130,6 +132,11 @@ const DirectMessageModal: FC<DirectMessageModalProps> = (props) => {
<SearchIcon className={styles.searchIcon} />
),
IndicatorSeparator: () => null,
MultiValue: (props) => (
<components.MultiValue {...props}>
{props.data.shortLabel}
</components.MultiValue>
),
}}
/>
{groupMessage && (
Expand Down

0 comments on commit 6880c8a

Please sign in to comment.