shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
66.57k stars 3.88k forks source link

[bug]: click combobox in form cause error #4106

Open siuming-qiu opened 1 month ago

siuming-qiu commented 1 month ago

Describe the bug

click combobox in form, and the website crash

Affected component/components

combobox

How to reproduce

20240627-010755

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Mac book air m3, chrome 126.0.6478.114

Before submitting

RushilJalal commented 1 month ago

Yes. This issue occurs for me too.

manjushsh commented 1 month ago

HI @siuming-qiu and @RushilJalal, This has been fixed in #4097

yohannestakata commented 1 month ago

HI @siuming-qiu and @RushilJalal, This has been fixed in #4097

Hi. I just came here after finding the issue just now. Please take a look at the combobox at the forms example

SachinCoder1 commented 1 month ago

Quick fix: You can fix it by using CommandList instead of CommandGroup

              <Command>
                <CommandInput placeholder="Search language..." />
                <CommandEmpty>No language found.</CommandEmpty>
                <CommandList>
                  {languages?.map((language) => (
                    <CommandItem
                      value={language.label}
                      key={language.value}
                      onSelect={() => {
                        form.setValue("language", language.value)
                      }}
                    >
                      <Check
                        className={cn(
                          "mr-2 h-4 w-4",
                          language.value === field.value
                            ? "opacity-100"
                            : "opacity-0"
                        )}
                      />
                      {language.label}
                    </CommandItem>
                  ))}
                </CommandList>
              </Command>
manjushsh commented 1 month ago

Hi @yohannestakata, I made changes in PR but it is not approved / merged yet. You are right @SachinCoder1