Skip to content

Commit b81eee3

Browse files
authored
Merge pull request #242 from carlosfpo/master
#240 Open native context menu if shift key is pressed
2 parents 7580dc0 + 08b4bee commit b81eee3

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

docs/api.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ Contextmenu Trigger Component
2727

2828
#### PropTypes
2929

30-
| Property | Type | Required? | Default | Description |
31-
|---------------|-------------------------|-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
32-
| id | String || | The unique identifier of the menu to be called. |
33-
| attributes | Object | | | The attributes will be passed directly passed to the root element of component. Use this to customize it like adding custom classes, adding `colspan` etc. |
34-
| collect | Function | | | A simple function which takes `props` as input and returns the data to be passed to contextmenu. |
35-
| disable | Boolean | | `false` | Prop to ignore right clicks and display the default browser context menu. |
36-
| holdToDisplay | Number | | `1000` | This is applicable only for touch screens. The time (in ms) for which, user has to hold down his/her finger before the menu is shown. **Note:** To disable the long press trigger on left-click just set a negative holdToDisplay value such as `-1` |
37-
| renderTag | String or React Element | | | The element inside which the Component must be wrapped. By default `div` is used. But this prop can used to customize it. |
30+
| Property | Type | Required? | Default | Description |
31+
|-------------------------|-------------------------|-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
32+
| id | String || | The unique identifier of the menu to be called. |
33+
| attributes | Object | | | The attributes will be passed directly passed to the root element of component. Use this to customize it like adding custom classes, adding `colspan` etc. |
34+
| collect | Function | | | A simple function which takes `props` as input and returns the data to be passed to contextmenu. |
35+
| disable | Boolean | | `false` | Prop to ignore right clicks and display the default browser context menu. |
36+
| holdToDisplay | Number | | `1000` | This is applicable only for touch screens. The time (in ms) for which, user has to hold down his/her finger before the menu is shown. **Note:** To disable the long press trigger on left-click just set a negative holdToDisplay value such as `-1` |
37+
| renderTag | String or React Element | | | The element inside which the Component must be wrapped. By default `div` is used. But this prop can used to customize it. |
38+
| disableIfShiftIsPressed | Boolean | | `false` | If true and shift is pressed, it will open the native browser context menu and ignore this custom component |
3839

3940
### `<MenuItem />`
4041

src/ContextMenuTrigger.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export default class ContextMenuTrigger extends Component {
1919
renderTag: PropTypes.oneOfType([
2020
PropTypes.node,
2121
PropTypes.func
22-
])
22+
]),
23+
disableIfShiftIsPressed: PropTypes.bool
2324
};
2425

2526
static defaultProps = {
@@ -29,7 +30,8 @@ export default class ContextMenuTrigger extends Component {
2930
holdToDisplay: 1000,
3031
renderTag: 'div',
3132
posX: 0,
32-
posY: 0
33+
posY: 0,
34+
disableIfShiftIsPressed: false
3335
};
3436

3537
touchHandled = false;
@@ -94,6 +96,7 @@ export default class ContextMenuTrigger extends Component {
9496

9597
handleContextClick = (event) => {
9698
if (this.props.disable) return;
99+
if (this.props.disableIfShiftIsPressed && event.shiftKey) return;
97100

98101
event.preventDefault();
99102
event.stopPropagation();

0 commit comments

Comments
 (0)