Skip to content

Commit

Permalink
Merge branch 'main' into ADM-975
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-yinyuan committed Jul 16, 2024
2 parents e4b6e3f + d97cb01 commit d411c00
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/src/layouts/ShareReportTrigger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import { CopyToClipboard } from 'react-copy-to-clipboard';
import ShareIcon from '@mui/icons-material/Share';
import LinkIcon from '@mui/icons-material/Link';
import { useAppSelector } from '@src/hooks';
import { useEffect, useState } from 'react';
import Popper from '@mui/material/Popper';
import Alert from '@mui/material/Alert';
import Link from '@mui/material/Link';
import { useState } from 'react';

const ShareReportTrigger = () => {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
Expand Down Expand Up @@ -50,18 +50,22 @@ const ShareReportTrigger = () => {
setShowAlert(true);
};

const handleClickAway = () => {
const resetStatus = () => {
setAnchorEl(null);
setShowAlert(false);
};

useEffect(() => {
resetStatus();
}, [showShareIcon]);

const open = Boolean(anchorEl);
const id = open ? 'simple-popper' : undefined;

return (
<>
{showShareIcon && (
<ClickAwayListener onClickAway={handleClickAway}>
<ClickAwayListener onClickAway={resetStatus}>
<ClickAwayContent>
<ShareIconWrapper title='Share' onClick={handleClick} aria-label='Share Report' disabled={!canShare}>
<ShareIcon />
Expand Down

0 comments on commit d411c00

Please sign in to comment.