Skip to content

Commit

Permalink
Merge pull request #1668 from visualize-admin/fix/menu-alignment
Browse files Browse the repository at this point in the history
fix: Menu alignment
  • Loading branch information
bprusinowski authored Jul 22, 2024
2 parents 386186e + 8652538 commit 12ab7be
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
55 changes: 31 additions & 24 deletions app/components/arrow-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
import { Menu, paperClasses, styled } from "@mui/material";

export const ArrowMenuTopBottom = styled(Menu)(({ theme }) => ({
const commonBeforeStyles: Partial<CSSStyleDeclaration> = {
content: '" "',
display: "block",
background: "white",
width: "10px",
height: "10px",
transform: "rotate(45deg)",
position: "absolute",
margin: "auto",
};

export const ArrowMenuTopCenter = styled(Menu)({
[`& .${paperClasses.root}`]: {
overflow: "visible",
"&:before": {
...commonBeforeStyles,
top: -5,
left: "0%",
right: 0,
},
},
});

export const ArrowMenuTopBottom = styled(Menu)({
[`& .${paperClasses.root}`]: {
overflowY: "visible",
overflowX: "visible",
overflow: "visible",
"&:before": {
content: '" "',
display: "block",
background: theme.palette.background.paper,
width: 10,
height: 10,
transform: "rotate(45deg)",
position: "absolute",
margin: "auto",
...commonBeforeStyles,
top: -5,
left: "calc(100% - 40px)",
right: 0,
},
},
}));
});

export const ArrowMenuBottomTop = styled(Menu)(({ theme }) => ({
export const ArrowMenuBottomTop = styled(Menu)({
[`& .${paperClasses.root}`]: {
overflowY: "visible",
overflowX: "visible",
overflow: "visible",
"&:before": {
content: '" "',
display: "block",
background: theme.palette.background.paper,
width: 10,
height: 10,
transform: "rotate(45deg)",
position: "absolute",
margin: "auto",
...commonBeforeStyles,
bottom: -5,
left: 0,
right: "calc(100% - 40px)",
},
},
}));
});
6 changes: 3 additions & 3 deletions app/components/chart-selection-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useClient } from "urql";
import { useDebounce } from "use-debounce";

import { extractChartConfigComponentIris } from "@/charts/shared/chart-helpers";
import { ArrowMenuTopBottom } from "@/components/arrow-menu";
import { ArrowMenuTopCenter } from "@/components/arrow-menu";
import { DuplicateChartMenuActionItem } from "@/components/chart-shared";
import Flex from "@/components/flex";
import { MenuActionItem } from "@/components/menu-action-item";
Expand Down Expand Up @@ -276,7 +276,7 @@ const TabsEditable = (props: TabsEditableProps) => {
) : null}

{tabsState.popoverType === "edit" ? (
<ArrowMenuTopBottom
<ArrowMenuTopCenter
id="chart-selection-popover"
open={tabsState.popoverOpen}
anchorEl={popoverAnchorEl}
Expand Down Expand Up @@ -322,7 +322,7 @@ const TabsEditable = (props: TabsEditableProps) => {
}}
/>
)}
</ArrowMenuTopBottom>
</ArrowMenuTopCenter>
) : null}
</>
);
Expand Down

0 comments on commit 12ab7be

Please sign in to comment.