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
62.96k stars 3.54k forks source link

[bug]: Error in examples/forms/account when clicked on Languages Trigger button #3962

Closed Z3RO-O closed 2 weeks ago

Z3RO-O commented 3 weeks ago

Describe the bug

When clicked on Languages Trigger button on examples in form on shadcn website the app crashes due to undefined value in that popover component. image

Affected component/components

Popover

How to reproduce

  1. Go to examples/forms/account
  2. Click on Language Button
  3. Error Page

Codesandbox/StackBlitz link

https://github.com/shadcn-ui/ui/tree/06cc0cdf3d080555d26abbe6639f2d7f6341ec73/apps/www/app/(app)/examples/forms/account

Logs

No response

System Info

Brave Brower

Before submitting

Rekl0w commented 3 weeks ago

I submitted a PR about it.

greatstefan commented 3 weeks ago

It happens the same with the combobox form. Please check

Z3RO-O commented 3 weeks ago

@Rekl0w Ok thanks for letting me know

Z3RO-O commented 3 weeks ago

@greatstefan yes it is the same.

greatstefan commented 3 weeks ago

Yes, the problem was because I had a "CommandGroup" component directly in "Command" and I had to wrap the "CommandGroup" in another component called "CommandList" and now works. So:

<CommandList>
  <CommandGroup>
    {options.map((option) => (
      <CommandItem
        key={option.value}
        onSelect={() => {
          onChange(option.value === value ? "" : option.value)
          setOpen(false)
        }}
      >
        <Check
          className={cn(
            "mr-2 h-4 w-4",
            value === option.value ? "opacity-100" : "opacity-0"
          )}
        />
        {option.label}
      </CommandItem>
    ))}
  </CommandGroup>
</CommandList>