Skip to content

Commit d3313d7

Browse files
[ClickAwayListener] Hide react-event-listener
1 parent f132c3c commit d3313d7

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

docs/scripts/buildApi.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ function getInheritance(src) {
5959
pathname = 'https://reactcommunity.org/react-transition-group/#Transition';
6060
break;
6161

62-
case 'EventListener':
63-
pathname = 'https://github.com/oliviertassinari/react-event-listener';
64-
break;
65-
6662
default:
6763
pathname = `/api/${kebabCase(component)}`;
6864
break;

packages/material-ui/src/ClickAwayListener/ClickAwayListener.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
// @inheritedComponent EventListener
2-
31
import React from 'react';
42
import ReactDOM from 'react-dom';
53
import PropTypes from 'prop-types';
64
import EventListener from 'react-event-listener';
75
import ownerDocument from '../utils/ownerDocument';
86
import { useForkRef } from '../utils/reactHelpers';
7+
import { exactProp } from '@material-ui/utils';
98

109
function useMountedRef() {
1110
const mountedRef = React.useRef(false);
@@ -24,13 +23,14 @@ function useMountedRef() {
2423
* For instance, if you need to hide a menu when people click anywhere else on your page.
2524
*/
2625
function ClickAwayListener(props) {
27-
const { children, mouseEvent, touchEvent, onClickAway, ...other } = props;
26+
const { children, mouseEvent, touchEvent, onClickAway } = props;
2827
const mountedRef = useMountedRef();
2928
const movedRef = React.useRef(false);
3029

3130
const nodeRef = React.useRef();
3231
// can be removed once we drop support for non ref forwarding class components
3332
const handleOwnRef = React.useCallback(ref => {
33+
// #StrictMode ready
3434
nodeRef.current = ReactDOM.findDOMNode(ref);
3535
}, []);
3636
const handleRef = useForkRef(children.ref, handleOwnRef);
@@ -88,7 +88,7 @@ function ClickAwayListener(props) {
8888
return (
8989
<React.Fragment>
9090
{React.cloneElement(children, { ref: handleRef })}
91-
<EventListener target="document" {...listenerProps} {...other} />
91+
<EventListener target="document" {...listenerProps} />
9292
</React.Fragment>
9393
);
9494
}
@@ -114,6 +114,11 @@ ClickAwayListener.propTypes = {
114114
touchEvent: PropTypes.oneOf(['onTouchStart', 'onTouchEnd', false]),
115115
};
116116

117+
if (process.env.NODE_ENV !== 'production') {
118+
// eslint-disable-next-line
119+
ClickAwayListener['propTypes' + ''] = exactProp(ClickAwayListener.propTypes);
120+
}
121+
117122
ClickAwayListener.defaultProps = {
118123
mouseEvent: 'onMouseUp',
119124
touchEvent: 'onTouchEnd',

packages/material-ui/src/MenuList/MenuList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const MenuList = React.forwardRef(function MenuList(props, ref) {
150150
};
151151

152152
const handleOwnRef = React.useCallback(refArg => {
153-
// StrictMode ready
153+
// #StrictMode ready
154154
listRef.current = ReactDOM.findDOMNode(refArg);
155155
}, []);
156156
const handleRef = useForkRef(handleOwnRef, ref);

pages/api/click-away-listener.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ For instance, if you need to hide a menu when people click anywhere else on your
2626

2727
The component cannot hold a ref.
2828

29-
Any other properties supplied will be provided to the root element ([EventListener](https://github.com/oliviertassinari/react-event-listener/)).
30-
31-
## Inheritance
32-
33-
The properties of the [EventListener](https://github.com/oliviertassinari/react-event-listener/) component, from react-event-listener, are also available.
34-
You can take advantage of this behavior to [target nested components](/guides/api/#spread).
3529

3630
## Demos
3731

0 commit comments

Comments
 (0)