最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - Input not working inside a Popover which is inside a dialog - ShadCn Next.js - Stack Overflow

programmeradmin4浏览0评论

Here in my colorpicker.jsx i have HexColorPicker and an input which shows hex code. I am able to use HexColorPicker but unable to use input. I have used this colorpicker inside and dialog which is I think is issue. If use this colorpicker outside dialog it is working but not inside dialog.

//colorpicker.jsx
<Popover onOpenChange={setOpen} open={open}>
  <PopoverTrigger asChild disabled={disabled} onBlur={onBlur}>
    <Button
      {...props}
      className={cn('block', className)}
      name={name}
      onClick={() => setOpen(true)}
      size="icon"
      style={{ backgroundColor: parsedValue }}
      variant="outline"
    >
      <div />
    </Button>
  </PopoverTrigger>
  <PopoverContent className="w-full" style={{ pointerEvents: "auto" }}>
    <HexColorPicker color={parsedValue} onChange={onChange} />
    <Input
      maxLength={7}
      onChange={(e) => onChange(e.currentTarget.value)}
      ref={ref}
      value={parsedValue}
    />
  </PopoverContent>
</Popover>

Here adding style={{ pointerEvents: "auto" }} on PopoverContent makes HexColorPicker usable but input is still not working.

Here is my dialog

<Dialog>
    <DialogTrigger asChild>
        <Button variant="secondary">QR Design Options</Button>
    </DialogTrigger>
    <DialogContent className="lg:max-w-[1000px] lg:max-h-[560px] overflow-hidden absolute" 
    onInteractOutside={(e) => { e.preventDefault(); }}>
        <ColorPicker name="qrColor" className="mt-2 w-8 h-8 rounded-lg items-center"
            value={designQRColor}
            onChange={(v) => {
            setQRColor(v);
            setOptions((options) => ({
                ...options,
                dotsOptions: {
                    ...options.dotsOptions,
                     color: v,
                },
            }));
          }}
        />
    </DialogContent>
</Dialog>

`

发布评论

评论列表(0)

  1. 暂无评论