ui: [Bug]: Combobox component error: Uncaught TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
Describe the bug
i am having the below error when i try to use Combobox component from shadcn-ui library, note that i have directly copy the code from there docs. The error happens when i click on the combobox. i am using the below versions:
"@hookform/resolvers": "^3.3.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@tanstack/react-table": "^8.12.0",
"axios": "^1.6.7",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cmdk": "^1.0.0",
"date-fns": "^3.3.1",
"dompurify": "^3.0.9",
"lucide-react": "^0.340.0",
"react": "^18.2.0",
"react-day-picker": "^8.10.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.50.1",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.0.1",
"react-router-dom": "^6.22.1",
"tailwind-merge": "^2.2.1",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/dompurify": "^3.0.5",
"@types/node": "^20.11.20",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.17",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"typescript": "^5.2.2",
"vite": "^5.1.4"
}
the error
Uncaught TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at Function.from (<anonymous>)
at A (cmdk.js?v=958c08d1:173:18)
at U2 (cmdk.js?v=958c08d1:139:13)
at cmdk.js?v=958c08d1:99:34
at cmdk.js?v=958c08d1:367:31
at Map.forEach (<anonymous>)
at cmdk.js?v=958c08d1:367:15
at commitHookEffectListMount (chunk-IIEKGORF.js?v=958c08d1:16904:34)
at commitLayoutEffectOnFiber (chunk-IIEKGORF.js?v=958c08d1:16992:23)
at commitLayoutMountEffects_complete (chunk-IIEKGORF.js?v=958c08d1:17976:17)
A @ cmdk.js?v=958c08d1:173
U2 @ cmdk.js?v=958c08d1:139
(anonymous) @ cmdk.js?v=958c08d1:99
(anonymous) @ cmdk.js?v=958c08d1:367
(anonymous) @ cmdk.js?v=958c08d1:367
commitHookEffectListMount @ chunk-IIEKGORF.js?v=958c08d1:16904
commitLayoutEffectOnFiber @ chunk-IIEKGORF.js?v=958c08d1:16992
commitLayoutMountEffects_complete @ chunk-IIEKGORF.js?v=958c08d1:17976
commitLayoutEffects_begin @ chunk-IIEKGORF.js?v=958c08d1:17965
commitLayoutEffects @ chunk-IIEKGORF.js?v=958c08d1:17916
commitRootImpl @ chunk-IIEKGORF.js?v=958c08d1:19349
commitRoot @ chunk-IIEKGORF.js?v=958c08d1:19273
performSyncWorkOnRoot @ chunk-IIEKGORF.js?v=958c08d1:18891
flushSyncCallbacks @ chunk-IIEKGORF.js?v=958c08d1:9135
(anonymous) @ chunk-IIEKGORF.js?v=958c08d1:18623
Show 15 more frames
Show less
chunk-IIEKGORF.js?v=958c08d1:16659 Uncaught TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at Function.from (<anonymous>)
at A (cmdk.js?v=958c08d1:173:18)
at U2 (cmdk.js?v=958c08d1:139:13)
at cmdk.js?v=958c08d1:99:34
at cmdk.js?v=958c08d1:367:31
at Map.forEach (<anonymous>)
at cmdk.js?v=958c08d1:367:15
at commitHookEffectListMount (chunk-IIEKGORF.js?v=958c08d1:16904:34)
at invokeLayoutEffectMountInDEV (chunk-IIEKGORF.js?v=958c08d1:18295:19)
at invokeEffectsInDev (chunk-IIEKGORF.js?v=958c08d1:19697:19)
A @ cmdk.js?v=958c08d1:173
U2 @ cmdk.js?v=958c08d1:139
(anonymous) @ cmdk.js?v=958c08d1:99
(anonymous) @ cmdk.js?v=958c08d1:367
(anonymous) @ cmdk.js?v=958c08d1:367
commitHookEffectListMount @ chunk-IIEKGORF.js?v=958c08d1:16904
invokeLayoutEffectMountInDEV @ chunk-IIEKGORF.js?v=958c08d1:18295
invokeEffectsInDev @ chunk-IIEKGORF.js?v=958c08d1:19697
commitDoubleInvokeEffectsInDEV @ chunk-IIEKGORF.js?v=958c08d1:19680
flushPassiveEffectsImpl @ chunk-IIEKGORF.js?v=958c08d1:19499
flushPassiveEffects @ chunk-IIEKGORF.js?v=958c08d1:19443
commitRootImpl @ chunk-IIEKGORF.js?v=958c08d1:19412
commitRoot @ chunk-IIEKGORF.js?v=958c08d1:19273
performSyncWorkOnRoot @ chunk-IIEKGORF.js?v=958c08d1:18891
flushSyncCallbacks @ chunk-IIEKGORF.js?v=958c08d1:9135
(anonymous) @ chunk-IIEKGORF.js?v=958c08d1:18623
Show 16 more frames
Show less
react-router-dom.js?v=958c08d1:3479 Error handled by React Router default ErrorBoundary: TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at Function.from (<anonymous>)
at A (cmdk.js?v=958c08d1:173:18)
at U2 (cmdk.js?v=958c08d1:139:13)
at cmdk.js?v=958c08d1:99:34
at cmdk.js?v=958c08d1:367:31
at Map.forEach (<anonymous>)
at cmdk.js?v=958c08d1:367:15
at commitHookEffectListMount (chunk-IIEKGORF.js?v=958c08d1:16904:34)
at invokeLayoutEffectMountInDEV (chunk-IIEKGORF.js?v=958c08d1:18295:19)
at invokeEffectsInDev (chunk-IIEKGORF.js?v=958c08d1:19697:19)
Affected component/components
Combobox
How to reproduce
1, create a new project using vite, just be sure to use the versions below i mention 2, add the combobox component and any other components that depend on it. 3, and copy paste the code from the docs and run your application
Codesandbox/StackBlitz link
No response
Logs
No response
System Info
Operating System: Windows 10
Browser: Chrome
Node.js Version (if applicable): v20.9.0
React Version: ^18.2.0,
React Router Version: 6.22.1
Before submitting
- I’ve made research efforts and searched the documentation
- I’ve searched for existing issues
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Reactions: 33
- Comments: 29
Commits related to this issue
- feat: Docker images, docker-compose (#25) - feat: add Dockerfile for backend - feat: add Dockerfile for frontend - refactor: move docker-compose.yml to project root - fix: revert frontend's cmdk l... — committed to ThreeBaristas/it-purple-hack by FEgor04 4 months ago
- 📦 Downgrade `cmdk` version via: https://github.com/shadcn-ui/ui/issues/2980 — committed to Gyozadaigaku/shadcn-design-system by Gyozadaigaku 3 months ago
@danilo-css @Gimhan001 Since You guys are very bored to read the issue that i have mentioned to solve the grayed out problem of the list items displayed, i will generalize the answer here once and for all the time.so here is the code that prevents the above error from happening:
so, warping the
CommandItemwithCommandListor as in the docs warpCommandGroupincludingCommandEmptywithCommandList.to solve the list items being grayed out, open
Commandcomponent by going tocomponents/ui/command.tsxand look forconst CommandItemand replace everydata-[disabled]withdata-[disabled='true']in theclassNameprop.Now you are good to go! This is because, in cmdk changenotes: The aria-disabled and aria-selected props will now be set to false by default, instead of being undefined.In the v.1 release notes https://github.com/pacocoursey/cmdk/releases/tag/v1.0.0
Rendering the Command.List part (CommandList if using shadcn) is now mandatory.So you need to add the CommandList beneath the Command component in your usecase to work @aynuayex
Wrapping
CommandListaroundCommandItem(s) worked for me.Wrapping the items inside CommandGroup in CommandList fixes the issue, but creates other issue, all the items get greyed out and unclickable:
This is the code I am using:
Thanks, but there are also other breaking change such as can’t select the items and all the available items are grayed out ,hover and other styles not working , so the Combobox component should be updated to reflect the changes
This seems to come from the library called cmdk cause when i fallback to older version ^0.2.0 it works with out problem, the newer version ^1.0.0. The Comobox component uses that library. Any fixes @pacocoursey, thanks in advance.
I just had to modify the cmdk to an older version of ^0.2.1 and it worked perfectly well.
use lower version of “cmdk”: “^1.0.0” ====> “cmdk”: "^0.2.0 "
Best option!thank you!
@aynuayex 🤝 Your solution worked for me. 4 hours of hysteria were wasted before your magical message.
Hi @aynuayex , today I faced another issue is can’t scroll when the content is too long, Have you ever seen that before?
Turn out the problems is millions, I used your code but it didnt hot reload. I re-run the web and it’s all good, Thank you mate 😄 Have a good day.