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
71.05k stars 4.27k forks source link

[bug]: Website crashes showing "Application error: a client-side exception has occurred (see the browser console for more information)." #4013

Open Gaurav-r-a-j opened 3 months ago

Gaurav-r-a-j commented 3 months ago

Describe the bug

When Navigating through the combobox components ' the last example which show a form for selecting language when you click on language the website crashes and show this error "Application error: a client-side exception has occurred (see the browser console for more information)."

Affected component/components

Combobox

How to reproduce

  1. Go to Combobox component
  2. Navigate to bottom of the page , to the form example showing Select Language Combobox .
  3. Click on "Select language" and the website will show the mentioned error.

Codesandbox/StackBlitz link

https://ui.shadcn.com/docs/components/combobox

Logs

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

System Info

able to reproduce in Chrome, Brave, and Arc

Before submitting

patelvivekdev commented 3 months ago

Wrap in CommandList.


import { CommandList } from '@/components/ui/command';

   ...

                    <CommandList>
                      <CommandEmpty>No language found.</CommandEmpty>
                      <CommandGroup>
                        {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>
                        ))}
                      </CommandGroup>
                    </CommandList>

   ...
JolomiTee commented 3 months ago

the solution @patelvivekdev offered worked for my implementation, and correctly shows the list of command items.