Skip to content

Commit 1e2d60b

Browse files
committed
Fix persist event issue
1 parent 97e9dc0 commit 1e2d60b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-click-away-listener",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "A simple click away listener built with React Hooks",
55
"main": "dist/react-click-away-listener.js",
66
"module": "dist/react-click-away-listener.es.js",

src/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ const ClickAwayListener: FunctionComponent<Props> = ({
2424
...props
2525
}) => {
2626
const node = useRef<HTMLElement>(null);
27-
const bubbledEvent: MutableRefObject<Events | null> = useRef(null);
27+
const bubbledEventTarget: MutableRefObject<EventTarget | null> = useRef(null);
2828

29-
const handleBubbledEvents = (event: Events | null) => {
30-
bubbledEvent.current = event;
29+
const handleBubbledEvents = (event: Events) => {
30+
bubbledEventTarget.current = event.target;
3131
};
3232

3333
useEffect(() => {
3434
const handleEvents = (event: Events): void => {
3535
if (
3636
(node.current && node.current.contains(event.target as Node)) ||
37-
(bubbledEvent.current && bubbledEvent.current.target === event.target)
37+
bubbledEventTarget.current === event.target
3838
) {
3939
return;
4040
}

0 commit comments

Comments
 (0)