diff --git a/src/components/ColorPicker.tsx b/src/components/ColorPicker.tsx index cb05cf446..5f0b190c9 100644 --- a/src/components/ColorPicker.tsx +++ b/src/components/ColorPicker.tsx @@ -369,6 +369,16 @@ export const ColorPicker = ({ }) => { const pickerButton = React.useRef(null); const coords = pickerButton.current?.getBoundingClientRect(); + const mainmenuContentCoords = document + .querySelector(".mainmenu-content") + ?.getBoundingClientRect(); + + const top = + coords && mainmenuContentCoords && coords.top - mainmenuContentCoords.top; + const left = + coords && + mainmenuContentCoords && + coords.right - mainmenuContentCoords.left; return (
@@ -396,8 +406,8 @@ export const ColorPicker = ({ className="color-picker-popover-container" style={{ position: "fixed", - top: coords?.top, - left: coords?.right, + top, + left, zIndex: 1, }} > diff --git a/src/components/dropdownMenu/DropdownMenu.scss b/src/components/dropdownMenu/DropdownMenu.scss index e1da2aec1..7f2b268c6 100644 --- a/src/components/dropdownMenu/DropdownMenu.scss +++ b/src/components/dropdownMenu/DropdownMenu.scss @@ -6,7 +6,8 @@ } .dropdown-menu { - position: absolute; + // position: absolute; + max-width: 250px; .radix-menuitem { &:focus-visible { @@ -15,15 +16,16 @@ } &--mobile { - bottom: 55px; - top: auto; - left: 0; - // TODO barnabasmolnar/mainmenu-radix - // double check rendering/styling on mobile - // width: 100%; - display: flex; - flex-direction: column; - row-gap: 0.75rem; + max-width: none; + // bottom: 55px; + // top: auto; + // left: 0; + // // TODO barnabasmolnar/mainmenu-radix + // // double check rendering/styling on mobile + // // width: 100%; + // display: flex; + // flex-direction: column; + // row-gap: 0.75rem; .dropdown-menu-container { padding: 8px 8px; diff --git a/src/components/dropdownMenu/DropdownMenu.tsx b/src/components/dropdownMenu/DropdownMenu.tsx index 962b67804..7d385ec3b 100644 --- a/src/components/dropdownMenu/DropdownMenu.tsx +++ b/src/components/dropdownMenu/DropdownMenu.tsx @@ -26,7 +26,7 @@ const DropdownMenu = ({ const MenuContentComp = getMenuContentComponent(children); return ( - + {MenuTriggerComp} {MenuContentComp} diff --git a/src/components/dropdownMenu/DropdownMenuContent.tsx b/src/components/dropdownMenu/DropdownMenuContent.tsx index 1450f2362..d60ddd97e 100644 --- a/src/components/dropdownMenu/DropdownMenuContent.tsx +++ b/src/components/dropdownMenu/DropdownMenuContent.tsx @@ -15,6 +15,7 @@ const MenuContent = ({ className = "", onSelect, style, + sideOffset, }: { children?: React.ReactNode; onClickOutside?: () => void; @@ -24,6 +25,7 @@ const MenuContent = ({ */ onSelect?: (event: Event) => void; style?: React.CSSProperties; + sideOffset?: number; }) => { const device = useDevice(); const menuRef = useOutsideClickHook(() => { @@ -42,7 +44,7 @@ const MenuContent = ({ style={style} data-testid="dropdown-menu" side="bottom" - sideOffset={4} + sideOffset={sideOffset ?? 4} align="start" > {/* the zIndex ensures this menu has higher stacking order, diff --git a/src/components/main-menu/MainMenu.tsx b/src/components/main-menu/MainMenu.tsx index bd0b2f532..d8ccf5856 100644 --- a/src/components/main-menu/MainMenu.tsx +++ b/src/components/main-menu/MainMenu.tsx @@ -50,6 +50,8 @@ const MainMenu = Object.assign( {HamburgerMenuIcon} { setAppState({ openMenu: null }); diff --git a/src/packages/excalidraw/example/App.tsx b/src/packages/excalidraw/example/App.tsx index d944fd68e..6bb7f192b 100644 --- a/src/packages/excalidraw/example/App.tsx +++ b/src/packages/excalidraw/example/App.tsx @@ -526,7 +526,7 @@ export default function App({ appTitle, useCustom, customArgs }: AppProps) { } > - Trigger + Submenu trigger {/* */} - Trigger + Another submenu trigger window.alert("You clicked on sub item")}