-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathindex.js
30 lines (26 loc) · 1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React from 'react';
import BasePopoverMenu from './BasePopoverMenu';
import {propTypes, defaultProps} from './popoverMenuPropTypes';
/**
* The web implementation of the menu needs to trigger actions before the popup closes
* When the modal is closed it's elements are destroyed
* Some browser will ignore interactions on elements that were removed or if the
* the action is not triggered immediately after a click
* This is a precaution against malicious scripts
*
* @param {Object} props
* @returns {React.ReactElement}
*/
const PopoverMenu = (props) => {
// Trigger the item's `onSelect` action as soon as clicked
const selectItem = (item) => {
item.onSelected();
props.onItemSelected(item);
};
// eslint-disable-next-line react/jsx-props-no-spreading
return <BasePopoverMenu {...props} onItemSelected={selectItem} />;
};
PopoverMenu.propTypes = propTypes;
PopoverMenu.defaultProps = defaultProps;
PopoverMenu.displayName = 'PopoverMenu';
export default PopoverMenu;