Skip to content

Commit

Permalink
fix: warning tooltip no longer fixed | prop cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony-Villa committed Feb 28, 2025
1 parent 74cc4a9 commit 4b1758c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion client/src/components/Layout/NavBarLogin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ const NavBarLogin = ({ classes, handleHamburgerMenuClick }) => {
</li>
);

useEffect(() => {
const handleScroll = () => {
const tooltip = document.querySelector(".popup-content");
const loginButton = document.getElementById("cy-login-menu-item");
if (tooltip && loginButton) {
const rect = loginButton.getBoundingClientRect();
tooltip.style.top = `${Math.floor(
rect.bottom + window.scrollY + 10
)}px`;
}
};

const scrollableElement = document.querySelector("#body");
scrollableElement.addEventListener("scroll", handleScroll);

return () => {
window.removeEventListener("scroll", handleScroll);
};
}, []);

return !account || !account.email ? (
!isCalculation ? (
<li className={clsx(classes.userLogin, classes.linkBlock)}>
Expand All @@ -82,7 +102,6 @@ const NavBarLogin = ({ classes, handleHamburgerMenuClick }) => {
open={tooltipOpen}
onClose={closeModal}
closeOnDocumentClick={false}
lockScroll={true}
trigger={<span style={{ cursor: "pointer" }}>{loginLink}</span>}
position="bottom right"
arrow={true}
Expand Down

0 comments on commit 4b1758c

Please sign in to comment.