orc-shared 5.9.0-dev.15 → 5.9.0-dev.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,6 +78,13 @@ var DropDownMenu = function DropDownMenu(_ref) {
78
78
  event.stopPropagation();
79
79
  setAnchorEl(null);
80
80
  };
81
+
82
+ // Even though we do nothing, we need to avoid mouse event propagation when the mouse
83
+ // button is released after hovering out the menu
84
+ var onMainMenuClick = function onMainMenuClick(event) {
85
+ event.preventDefault();
86
+ event.stopPropagation();
87
+ };
81
88
  var onMenuItemClick = function onMenuItemClick(action, itemContext) {
82
89
  return function (event) {
83
90
  onClose(event);
@@ -110,6 +117,7 @@ var DropDownMenu = function DropDownMenu(_ref) {
110
117
  },
111
118
  id: "scope-menu",
112
119
  open: isOpened,
120
+ onClick: onMainMenuClick,
113
121
  onClose: onClose,
114
122
  autoFocus: autoFocus,
115
123
  anchorEl: anchorEl
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "5.9.0-dev.15",
3
+ "version": "5.9.0-dev.16",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -47,6 +47,13 @@ const DropDownMenu = ({ payload, menuItems, children, dropDownMenuProps = new Dr
47
47
  setAnchorEl(null);
48
48
  };
49
49
 
50
+ // Even though we do nothing, we need to avoid mouse event propagation when the mouse
51
+ // button is released after hovering out the menu
52
+ const onMainMenuClick = event => {
53
+ event.preventDefault();
54
+ event.stopPropagation();
55
+ };
56
+
50
57
  const onMenuItemClick = (action, itemContext) => event => {
51
58
  onClose(event);
52
59
  action(payload, itemContext);
@@ -76,6 +83,7 @@ const DropDownMenu = ({ payload, menuItems, children, dropDownMenuProps = new Dr
76
83
  classes={{ paper: classes.menu }}
77
84
  id="scope-menu"
78
85
  open={isOpened}
86
+ onClick={onMainMenuClick}
79
87
  onClose={onClose}
80
88
  autoFocus={autoFocus}
81
89
  anchorEl={anchorEl}
@@ -8,6 +8,7 @@ import Icon from "../DataDisplay/Icon";
8
8
  import DropDownMenu from "./DropDownMenu";
9
9
  import { ignoreConsoleError } from "../../../utils/testUtils";
10
10
  import { TestWrapper, createMuiTheme } from "./../../../utils/testUtils";
11
+ import Menu from "@material-ui/core/Menu";
11
12
 
12
13
  describe("DropDownMenu", () => {
13
14
  let store, menuItems, container;
@@ -92,4 +93,27 @@ describe("DropDownMenu", () => {
92
93
  expect(menuItems[0].action, "to have calls satisfying", [{ args: [payload, "aContext"] }]);
93
94
  expect(menuItems[1].action, "to have calls satisfying", [{ args: [payload, "myContext"] }]);
94
95
  });
96
+
97
+ it("should handle onClick event on the menu", () => {
98
+ const payload = "payload";
99
+
100
+ const component = (
101
+ <Provider store={store}>
102
+ <DropDownMenu payload={payload} menuItems={menuItems} />
103
+ </Provider>
104
+ );
105
+
106
+ const mountedComponent = mount(component);
107
+
108
+ const event = {
109
+ preventDefault: sinon.spy().named("preventDefault"),
110
+ stopPropagation: sinon.spy().named("stopPropagation"),
111
+ };
112
+
113
+ const dropDownMenu = mountedComponent.find(Menu).at(0);
114
+ dropDownMenu.invoke("onClick")(event);
115
+
116
+ expect(event.preventDefault, "was called");
117
+ expect(event.stopPropagation, "was called");
118
+ });
95
119
  });