Skip to content

Close on outside click #46

Open
Open
@vickyRathee

Description

@vickyRathee

When the mutli-select is used in dialog, it doesn't close the popover on outside click. For example, I selected team members and just clicked on "Submit" button which didn't triggered the setIsPopoverOpen: false and resulted in screen freeze due to pointer-events: none; was never removed from the body.

 <Dialog open={isOpen} onOpenChange={onClose}>
      <DialogContent className="max-w-2xl">
        <DialogHeader>
          <DialogTitle>{service ? "Edit Service" : "Add Service"}</DialogTitle>
        </DialogHeader>

        <form onSubmit={handleSubmit} className="space-y-6">
            <div className="space-y-2">
              <Label>Service Name</Label>
              <Input
                value={formData.name}
                onChange={(e) =>
                  setFormData({ ...formData, name: e.target.value })
                }
                placeholder="Enter service name"
                required
              />
            </div>
            <div className="space-y-2">
              <Label>Team Members</Label>
              <MultiSelect
                options={users.map((x) => ({
                  label: `${x.name}`,
                  value: `${x.user_id}`,
                }))}
                defaultValue={formData.members}
                onValueChange={(members) =>
                  setFormData({ ...formData, members })
                }
                placeholder="Select members..."
                modalPopover={true}
              />
            </div>
          </div>

          <div className="flex justify-end gap-2">
            <Button type="submit">
               Submit
            </Button>
          </div>
        </form>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions