diff --git a/CHANGELOG.md b/CHANGELOG.md index b6f463c..92a146f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Unreleased +* [Make `IActionParamForRun.closeContextMenu` optional](https://github.com/flower-platform/react-timeline-10000/pull/104) * [Add `nowMarkerLiveUpdate` property that live updates the now marker](https://github.com/flower-platform/react-timeline-10000/pull/108) * [Fix scrollbars that hide content on gantt/table](https://github.com/flower-platform/react-timeline-10000/pull/103) * [Drag to create can start on top of an existing item](https://github.com/flower-platform/react-timeline-10000/pull/101) diff --git a/src/components/ContextMenu/ContextMenu.tsx b/src/components/ContextMenu/ContextMenu.tsx index 63a9f59..611a065 100644 --- a/src/components/ContextMenu/ContextMenu.tsx +++ b/src/components/ContextMenu/ContextMenu.tsx @@ -1,22 +1,14 @@ import React from 'react'; -import { Menu, Popup, StrictPopupProps } from 'semantic-ui-react'; +import { Menu, Popup } from 'semantic-ui-react'; import { IAction, IActionParamForRun } from './IAction'; import { TestsAreDemoCheat, createTestids } from '@famiprog-foundation/tests-are-demo'; import _ from 'lodash'; export type Point = { x: number, y: number }; - -type Position = StrictPopupProps["position"]; - -type IParamsForAction = { - selection: any[]; - position?: Position; - [key: string]: any; -} interface ContextMenuProps { actions: IAction[]; - paramsForAction: IParamsForAction; + paramsForAction: IActionParamForRun; /** * if undefined => the menu is closed else {x, y} position where the menu should open */ diff --git a/src/components/ContextMenu/IAction.ts b/src/components/ContextMenu/IAction.ts index 07b5d69..8b7638a 100644 --- a/src/components/ContextMenu/IAction.ts +++ b/src/components/ContextMenu/IAction.ts @@ -1,17 +1,24 @@ import React from "react" -import { IconProps, SemanticShorthandItem } from "semantic-ui-react" +import { IconProps, SemanticShorthandItem, StrictPopupProps } from "semantic-ui-react" import { Point } from "./ContextMenu" // TODO RM34271 let's get rid of IActionParamForRun. It overcomplicates the inheritance. We'll have here closeContextMenu() that won't do anything. // export interface IActionParam { // selection: S[] +type Position = StrictPopupProps["position"]; + export interface IActionParam { selection: any[] } export interface IActionParamForRun extends IActionParam { - closeContextMenu: () => void, - + /** + * Function to close the context menu. + * This is marked as optional because users will pass their actionParamForRun without this field. + * However, it will ALWAYS be populated internally by the ContextMenu component before being passed to action handlers. + */ + closeContextMenu?: () => void, + /** * By default the context menu closes immediately after the action is run * If the user wants to avoid the closing of the menu after action runs he needs to set this property to true @@ -23,6 +30,10 @@ export interface IActionParamForRun extends IActionParam { * It contains the mouse coordinates, obtained from onClick event of an action */ eventPoint?: Point + + position?: Position; + + [key: string]: any; } // TODO RM34271 CS: for the moment it's not clear why we need this. It's not used by the lib. And currently, the task of opening