mirror of
https://github.com/coaidev/coai.git
synced 2025-05-21 14:00:13 +09:00
fix: fix multi combobox value is not in list candidate set issue
fix: fix multi combobox value is not in list candidate set issue Co-Authored-By: Minghan Zhang <112773885+zmh-program@users.noreply.github.com>
This commit is contained in:
parent
03512d0fc8
commit
079c55d752
@ -44,9 +44,7 @@ function Announcement() {
|
|||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className={`announcement-dialog flex-dialog`}>
|
<DialogContent className={`announcement-dialog flex-dialog`}>
|
||||||
<DialogHeader notTextCentered>
|
<DialogHeader notTextCentered>
|
||||||
<DialogTitle
|
<DialogTitle className={"flex flex-row items-center select-none"}>
|
||||||
className={"flex flex-row items-center select-none"}
|
|
||||||
>
|
|
||||||
<Bell className="inline-block w-4 h-4 mr-2" />
|
<Bell className="inline-block w-4 h-4 mr-2" />
|
||||||
<p className={`translate-y-[-1px]`}>{t("announcement")}</p>
|
<p className={`translate-y-[-1px]`}>{t("announcement")}</p>
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
@ -55,7 +53,9 @@ function Announcement() {
|
|||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<DialogCancel onClick={() => setOpen(false)}>{t("close")}</DialogCancel>
|
<DialogCancel onClick={() => setOpen(false)}>
|
||||||
|
{t("close")}
|
||||||
|
</DialogCancel>
|
||||||
<DialogAction onClick={() => setOpen(false)}>
|
<DialogAction onClick={() => setOpen(false)}>
|
||||||
<Check className="w-4 h-4 mr-1" />
|
<Check className="w-4 h-4 mr-1" />
|
||||||
{t("i-know")}
|
{t("i-know")}
|
||||||
|
@ -39,8 +39,8 @@ export function Combobox({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [open, setOpen] = React.useState(defaultOpen ?? false);
|
const [open, setOpen] = React.useState(defaultOpen ?? false);
|
||||||
const valueList = React.useMemo((): string[] => {
|
const valueList = React.useMemo((): string[] => {
|
||||||
// list set
|
// list set (if some element in current value is not in list, it will be added)
|
||||||
const set = new Set(list);
|
const set = new Set([...list, value]);
|
||||||
return [...set];
|
return [...set];
|
||||||
}, [list]);
|
}, [list]);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ const DialogHeader = ({
|
|||||||
className,
|
className,
|
||||||
notTextCentered,
|
notTextCentered,
|
||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement> & {notTextCentered?: boolean}) => (
|
}: React.HTMLAttributes<HTMLDivElement> & { notTextCentered?: boolean }) => (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex flex-col space-y-1.5 sm:text-left",
|
"flex flex-col space-y-1.5 sm:text-left",
|
||||||
@ -121,10 +121,11 @@ const DialogCancel = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
({ className, variant, ...props }, ref) => (
|
({ className, variant, ...props }, ref) => (
|
||||||
<Button
|
<Button
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
className={className}
|
||||||
variant={variant ?? "outline"}
|
variant={variant ?? "outline"}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
DialogCancel.displayName = "DialogCancel";
|
DialogCancel.displayName = "DialogCancel";
|
||||||
@ -133,10 +134,11 @@ const DialogAction = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
({ className, variant, ...props }, ref) => (
|
({ className, variant, ...props }, ref) => (
|
||||||
<Button
|
<Button
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
className={cn("mb-2 md:mb-0", className)}
|
||||||
variant={variant ?? "default"}
|
variant={variant ?? "default"}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
DialogAction.displayName = "DialogAction";
|
DialogAction.displayName = "DialogAction";
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ export function MultiCombobox({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [open, setOpen] = React.useState(defaultOpen ?? false);
|
const [open, setOpen] = React.useState(defaultOpen ?? false);
|
||||||
const valueList = React.useMemo((): string[] => {
|
const valueList = React.useMemo((): string[] => {
|
||||||
// list set
|
// list set (if some element in current value is not in list, it will be added)
|
||||||
const set = new Set(list);
|
const set = new Set([...list, ...value]);
|
||||||
return [...set];
|
return [...set];
|
||||||
}, [list]);
|
}, [list]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user