Add prevent default to action toggle

This commit is contained in:
Alex Holliday committed 2024-08-02 10:53:24 -07:00
1 parent b5e12dabc4
commit 6dde4646d8
2 files changed
+13 -4

No files matched your search

+3 -1
View File
@@ -135,7 +135,9 @@ const BasicTable = ({ data, paginated, reversed, rowsPerPage = 5 }) => {
{displayData.map((row) => { {displayData.map((row) => {
return ( return (
<TableRow <TableRow
sx={{ cursor: row.handleClick ? "pointer" : "default" }} sx={{
cursor: row.handleClick ? "pointer" : "default",
}}
key={row.id} key={row.id}
onClick={row.handleClick ? row.handleClick : null} onClick={row.handleClick ? row.handleClick : null}
> >
+10 -3
View File
@@ -60,6 +60,7 @@ const Monitors = () => {
const [anchorEl, setAnchorEl] = useState(null); const [anchorEl, setAnchorEl] = useState(null);
const [actions, setActions] = useState({}); const [actions, setActions] = useState({});
const openMenu = (event, id, url) => { const openMenu = (event, id, url) => {
event.preventDefault();
setAnchorEl(event.currentTarget); setAnchorEl(event.currentTarget);
setActions({ id: id, url: url }); setActions({ id: id, url: url });
}; };
@@ -137,7 +138,7 @@ const Monitors = () => {
return { return {
id: monitor._id, id: monitor._id,
// disabled for now // disabled for now
// handleClick: () => navigate(`/monitors/${monitor._id}`), handleClick: () => navigate(`/monitors/${monitor._id}`),
data: [ data: [
{ id: idx, data: <Host params={params} /> }, { id: idx, data: <Host params={params} /> },
{ {
@@ -163,7 +164,10 @@ const Monitors = () => {
<> <>
<IconButton <IconButton
aria-label="monitor actions" aria-label="monitor actions"
onClick={(event) => openMenu(event, monitor._id, monitor.url)} onClick={(event) => {
event.stopPropagation();
openMenu(event, monitor._id, monitor.url);
}}
sx={{ sx={{
"&:focus": { "&:focus": {
outline: "none", outline: "none",
@@ -227,7 +231,10 @@ const Monitors = () => {
onClose={closeMenu} onClose={closeMenu}
> >
<MenuItem <MenuItem
onClick={() => window.open(actions.url, "_blank", "noreferrer")} onClick={(event) => {
event.stopPropagation();
window.open(actions.url, "_blank", "noreferrer");
}}
> >
Open site Open site
</MenuItem> </MenuItem>