diff --git a/package.json b/package.json index d20f1e1..7a58ec3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "griller", "license": "MIT", - "version": "1.0.14", + "version": "1.0.15", "private": false, "repository": { "url": "https://github.com/mvriu5/griller" diff --git a/src/app/lab/page.tsx b/src/app/lab/page.tsx index 641464f..a0a71b0 100644 --- a/src/app/lab/page.tsx +++ b/src/app/lab/page.tsx @@ -53,7 +53,7 @@ export default function Home() { return ( -
+
Customize
diff --git a/src/lib/combobox.tsx b/src/lib/combobox.tsx index a55f025..c62b440 100644 --- a/src/lib/combobox.tsx +++ b/src/lib/combobox.tsx @@ -28,6 +28,8 @@ const Combobox = forwardRef(({ title, values, label, preSe const [open, setOpen] = useState(false); const [dropdownPosition, setDropdownPosition] = useState<{ top: number; left: number }>({ top: 0, left: 0 }); const itemRef = useRef(null); + const menuRef = useRef(null); + const portalRef = useRef(null); useEffect(() => { if (open && itemRef.current) { @@ -36,9 +38,12 @@ const Combobox = forwardRef(({ title, values, label, preSe } }, [open]); - const menuRef = useOutsideClick((e) => { - e.stopPropagation(); - setOpen(false); + useOutsideClick((e) => { + if ((menuRef.current && !menuRef.current.contains(e.target as Node)) && + (portalRef.current && !portalRef.current.contains(e.target as Node))) + { + setOpen(false); + } }); useImperativeHandle(ref, () => ({ @@ -58,36 +63,37 @@ const Combobox = forwardRef(({ title, values, label, preSe {label && {label}} -
setOpen(!open)} - ref={itemRef} - > - {value} - {open ? : } -
- - {open && - -
- {values.map((item, index) => ( -
handleValueChange(item)} - > - {item} - {value === item && } -
- ))} -
-
- } +
+
setOpen(!open)} + ref={itemRef} + > + {value} + {open ? : } +
+ {open && + +
+ {values.map((item, index) => ( +
handleValueChange(item)} + > + {item} + {value === item && } +
+ ))} +
+
+ } +
); }); diff --git a/src/lib/copybutton.tsx b/src/lib/copybutton.tsx index 1b60258..67b4033 100644 --- a/src/lib/copybutton.tsx +++ b/src/lib/copybutton.tsx @@ -1,7 +1,7 @@ "use client"; import React, {HTMLAttributes, useEffect, useState} from "react"; -import {Check, Clipboard} from "lucide-react"; +import {Check, Copy} from "lucide-react"; import {AnimatePresence, motion} from "framer-motion"; interface CopyButtonProps extends HTMLAttributes { @@ -46,7 +46,7 @@ const CopyButton: React.FC = ({ copyText, className, ...props } exit={{ opacity: 0, scale: 0.4, y: '100%' }} transition={{ duration: 0.2 }} > - + )} diff --git a/src/lib/switchbutton.tsx b/src/lib/switchbutton.tsx index b78712f..4b1d478 100644 --- a/src/lib/switchbutton.tsx +++ b/src/lib/switchbutton.tsx @@ -29,13 +29,13 @@ const SwitchButton = forwardRef(({ label, ti
{label && {label}} -
-
+
handleChange(!value)} > {titleOne}
-
handleChange(!value)} > {titleTwo}