dropdown

dropdown open in portal for using table in react

dropdown open in portal for using table in react

import React, { useState, useRef, useEffect } from "react"; import ReactDOM from "react-dom"; const PortalWrapper = React.forwardRef(({ children }, ref) => { const [openDropdownMenu, setOpenDropdownMenu] = useState(false); const [position, setPosition] = useState({ left: 0, top: 0, width: "100%", }); const dropdownRef = useRef(null); const handleDropdDownClick = () => { setOpenDropdownMenu(!openDropdownMenu); if (ref && "current" in ref && ref.current) { const { top, left, height } = ref.current.getBoundingClientRect(); setPosition({ top: top + height, left, width: `${ref.current.clientWidth}px`, }); } }; useEffect(() => { if (openDropdownMenu && dropdownRef.current) { dropdownRef.current.style.top = `${position.top}px`; dropdownRef.current.style.left = `${position.left}px`; dropdownRef.current.style.display = "none"; } }, [openDropdownMenu, position]); return…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.