You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import React from "react";
import { useRef, useState, Fragment } from "react";
import Image from "next/image";
//import Navbar from 'react-bootstrap/Navbar';
//import Nav from 'react-bootstrap/Nav';
//import NavDropdown from 'react-bootstrap/NavDropdown';
import Link from "next/link";
import { Popover, Transition } from "@headlessui/react";
import { FaChevronDown } from "react-icons/fa";
import Test from "./Test";
import Batman from "./Batman";
import FlyOutMenu from "./FlyOutMenu"
const solutions = [
{
name: "Insights",
description: "Measure actions your users take",
href: "##",
icon: IconOne,
},
{
name: "Automations",
description: "Create your own targeted content",
href: "##",
icon: IconTwo,
},
{
name: "Reports",
description: "Keep track of your growth",
href: "##",
icon: IconThree,
},
];
panelRef &&
panelRef.current?.dispatchEvent(
new KeyboardEvent("keydown", {
key: "Escape",
bubbles: true,
cancelable: true,
})
);
console.log("In Close Menu At end - panelRef= " + panelRef)
};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to get the PopOver Panel to close using the onMouseLeave event. I can get my panel to open using onMouseEnter.
Any insight would be appreciated.
Here is a link to the codesandbox
https://dc418.csb.app/
Here is the code.
import React from "react";
import { useRef, useState, Fragment } from "react";
import Image from "next/image";
//import Navbar from 'react-bootstrap/Navbar';
//import Nav from 'react-bootstrap/Nav';
//import NavDropdown from 'react-bootstrap/NavDropdown';
import Link from "next/link";
import { Popover, Transition } from "@headlessui/react";
import { FaChevronDown } from "react-icons/fa";
import Test from "./Test";
import Batman from "./Batman";
import FlyOutMenu from "./FlyOutMenu"
const solutions = [
{
name: "Insights",
description: "Measure actions your users take",
href: "##",
icon: IconOne,
},
{
name: "Automations",
description: "Create your own targeted content",
href: "##",
icon: IconTwo,
},
{
name: "Reports",
description: "Keep track of your growth",
href: "##",
icon: IconThree,
},
];
export default function Header() {
const buttonRef = useRef(null);
const panelRef = useRef(null);
const useHover = true;
const timeoutDuration = 200;
const [displayMenu, setDisplayMenu] = useState(false);
//const element= document.getElementById("flyout-menu");
let timeout;
function openPopover(e) {
//e.target.style.background = 'red';
//Popover.Button.popoverState = 0;
//this.buttonRef.click();
//buttonRef && buttonRef.current.click();
}
const openMenu = () => {
//console.log("In open menu");
buttonRef && buttonRef.current.click();
};
const closeMenu = () => {
console.log("In Close Menu - panelRef= " + panelRef);
const onMouseEnter = (closed) => {
//console.log("In onMouseEnter - closed = " + closed);
clearTimeout(timeout);
//console.log("In onMouseEnter - Called OpenMenu");
closed && openMenu();
//console.log("In onMouseEnter At End - closed = " + closed);
};
const onMouseLeave = (open, debug) => {
//console.log("In onMouseLeave - closed = " + closed + " Open = " + open);
open && (timeout = setTimeout(() => closeMenu(), timeoutDuration));
//console.log("In onMouseLeave - At End closed = " + closed + " Open = " + open);
};
return (
HOME
<div className="text-primary px-5" onMouseEnter={() => setDisplayMenu(true)}>
WHAT WE DO
{({ displayMenu}) => (
<>
<div onMouseLeave={() => setDisplayMenu(false)}>
✅ Alphanumeric Characters
⛔️ *
</>
)}
);
}
function IconOne() {
return (
);
}
function IconTwo() {
return (
);
}
function IconThree() {
return (
);
}
Beta Was this translation helpful? Give feedback.
All reactions