Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Combobox is not working inside a dialog #4277

Open
2 tasks done
NatnaelMalike opened this issue Jul 13, 2024 · 2 comments
Open
2 tasks done

[bug]: Combobox is not working inside a dialog #4277

NatnaelMalike opened this issue Jul 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@NatnaelMalike
Copy link

NatnaelMalike commented Jul 13, 2024

Describe the bug

the combobox elements are not able to be selected and the search input also can't be focused i use the same combobox outside the dialog it works fine

Affected component/components

Combobox, Dialog

How to reproduce

  1. install popover and command
  2. install dialog and use form
  3. put the combobox inside form and the form inside the dialog
  4. try to access the combobox

The Code: for Combobox

<FormField
                    control={form.control}
                    name="department"
                    render={({ field }) => (
                        <FormItem>
                            <FormLabel>Department</FormLabel>
                            <Popover>
                                <PopoverTrigger asChild>
                                    <FormControl>
                                        <Button
                                            variant="outline"
                                            role="combobox"
                                            className={cn(
                                                "w-full justify-between",
                                                !field.value &&
                                                    "text-muted-foreground"
                                            )}>
                                            {field.value
                                                ? departments.find(
                                                      (department) =>
                                                          department._id ===
                                                          field.value
                                                  )?.name
                                                : "Select Your Department"}
                                            <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
                                        </Button>
                                    </FormControl>
                                </PopoverTrigger>
                                <PopoverContent className="p-0 max-h-80 overflow-y-scroll">
                                    <Command>
                                        <CommandInput
                                            placeholder="Search Department..."
                                            className="h-9 pointer-events-auto"
                                        />
                                        <CommandEmpty>
                                            No Department found.
                                        </CommandEmpty>

                                        <CommandGroup>
                                            {departments.map((department) => (
                                                <CommandItem
                                                    value={department._id}
                                                    key={department._id}
                                                    onSelect={() => {
                                                        form.setValue(
                                                            "department",
                                                            department._id
                                                        );
                                                    }}>
                                                    {department.name}
                                                    <Check
                                                        className={cn(
                                                            "ml-auto h-4 w-4",
                                                            department._id ===
                                                                field.value
                                                                ? "opacity-100"
                                                                : "opacity-0"
                                                        )}
                                                    />
                                                </CommandItem>
                                            ))}
                                        </CommandGroup>
                                    </Command>
                                </PopoverContent>
                            </Popover>
                            <FormDescription className="hidden lg:block">
                                This is the name of the Your Department.
                            </FormDescription>
                            <FormMessage />
                        </FormItem>
                    )}
                />
 

The Code: for DialogComponent

<Dialog open={open} onOpenChange={handleDialogChange}>
            <DialogTrigger asChild>
                <Button className="space-x-2 bg-teal-800" onClick={handleDialogChange}>
                    <SquarePlus />
                    <p className="text-base">Add {entity}</p>
                </Button>
            </DialogTrigger>
            <DialogContent className="max-sm:w-11/12">
                <DialogHeader>
                    <DialogTitle className="text-xl text-center mb-2">Add {entity}</DialogTitle>
                    <DialogDescription className="text-base text-center mb-2">
                        Adding a new {entity} to the system
                    </DialogDescription>
                </DialogHeader>
                <DialogContext.Provider value={handleDialogChange}>
                    {children}
                </DialogContext.Provider>
            </DialogContent>
        </Dialog>

Logs

No response

System Info

React, javascript

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@NatnaelMalike NatnaelMalike added the bug Something isn't working label Jul 13, 2024
@rohit-ks
Copy link

Hey, did you find any solution for this?

@rohit-ks
Copy link

This fixed my issue.

#235 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants