Skip to content

Commit

Permalink
fix: fix multi combobox value is not in list candidate set issue
Browse files Browse the repository at this point in the history
fix: fix multi combobox value is not in list candidate set issue
Co-Authored-By: Minghan Zhang <[email protected]>
  • Loading branch information
Sh1n3zZ and zmh-program committed Mar 30, 2024
1 parent 03512d0 commit 079c55d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions app/src/components/app/Announcement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ function Announcement() {
</DialogTrigger>
<DialogContent className={`announcement-dialog flex-dialog`}>
<DialogHeader notTextCentered>
<DialogTitle
className={"flex flex-row items-center select-none"}
>
<DialogTitle className={"flex flex-row items-center select-none"}>
<Bell className="inline-block w-4 h-4 mr-2" />
<p className={`translate-y-[-1px]`}>{t("announcement")}</p>
</DialogTitle>
Expand All @@ -55,7 +53,9 @@ function Announcement() {
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogCancel onClick={() => setOpen(false)}>{t("close")}</DialogCancel>
<DialogCancel onClick={() => setOpen(false)}>
{t("close")}
</DialogCancel>
<DialogAction onClick={() => setOpen(false)}>
<Check className="w-4 h-4 mr-1" />
{t("i-know")}
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/ui/combo-box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export function Combobox({
const { t } = useTranslation();
const [open, setOpen] = React.useState(defaultOpen ?? false);
const valueList = React.useMemo((): string[] => {
// list set
const set = new Set(list);
// list set (if some element in current value is not in list, it will be added)
const set = new Set([...list, value]);
return [...set];
}, [list]);

Expand Down
8 changes: 5 additions & 3 deletions app/src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const DialogHeader = ({
className,
notTextCentered,
...props
}: React.HTMLAttributes<HTMLDivElement> & {notTextCentered?: boolean}) => (
}: React.HTMLAttributes<HTMLDivElement> & { notTextCentered?: boolean }) => (
<div
className={cn(
"flex flex-col space-y-1.5 sm:text-left",
Expand Down Expand Up @@ -121,10 +121,11 @@ const DialogCancel = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, ...props }, ref) => (
<Button
ref={ref}
className={className}
variant={variant ?? "outline"}
{...props}
/>
)
),
);

DialogCancel.displayName = "DialogCancel";
Expand All @@ -133,10 +134,11 @@ const DialogAction = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, ...props }, ref) => (
<Button
ref={ref}
className={cn("mb-2 md:mb-0", className)}
variant={variant ?? "default"}
{...props}
/>
)
),
);
DialogAction.displayName = "DialogAction";

Expand Down
4 changes: 2 additions & 2 deletions app/src/components/ui/multi-combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export function MultiCombobox({
const { t } = useTranslation();
const [open, setOpen] = React.useState(defaultOpen ?? false);
const valueList = React.useMemo((): string[] => {
// list set
const set = new Set(list);
// list set (if some element in current value is not in list, it will be added)
const set = new Set([...list, ...value]);
return [...set];
}, [list]);

Expand Down

0 comments on commit 079c55d

Please sign in to comment.