From a3b492333ec8416d5b73d7678ad8f5e2528afc3e Mon Sep 17 00:00:00 2001 From: mushka Date: Fri, 7 Oct 2022 15:58:55 +0300 Subject: [PATCH] complete overhaul of itemContextOptions component, separated to contextOptions and ContextOptionsButton and fixed issue with sub-leafs --- .../ItemTitle/ItemContextOptions.js | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/client/src/pages/Home/InfoPanel/Body/sub-components/ItemTitle/ItemContextOptions.js b/packages/client/src/pages/Home/InfoPanel/Body/sub-components/ItemTitle/ItemContextOptions.js index 2cf109bc55..d34a12034e 100644 --- a/packages/client/src/pages/Home/InfoPanel/Body/sub-components/ItemTitle/ItemContextOptions.js +++ b/packages/client/src/pages/Home/InfoPanel/Body/sub-components/ItemTitle/ItemContextOptions.js @@ -1,9 +1,11 @@ -import React from "react"; +import React, { useRef, useEffect } from "react"; import styled from "styled-components"; -import { inject } from "mobx-react"; -import { withTranslation } from "react-i18next"; -import { ContextMenuButton } from "@docspace/components"; +import { + ContextMenu, + ContextMenuButton, + IconButton, +} from "@docspace/components"; import ContextHelper from "../../helpers/ContextHelper"; @@ -11,9 +13,16 @@ const StyledItemContextOptions = styled.div` margin-left: auto; `; -const ItemContextOptions = ({ selection, setBufferSelection, ...props }) => { +const ItemContextOptions = ({ + selection, + setBufferSelection, + itemTitleRef, + ...props +}) => { if (!selection) return null; + const contextMenuRef = useRef(); + const contextHelper = new ContextHelper({ selection, ...props, @@ -21,17 +30,26 @@ const ItemContextOptions = ({ selection, setBufferSelection, ...props }) => { const setItemAsBufferSelection = () => setBufferSelection(selection); + const onContextMenu = (e) => { + e.button === 2; + if (!contextMenuRef.current.menuRef.current) itemTitleRef.current.click(e); + contextMenuRef.current.show(e); + }; + return ( + );