Skip to content

Commit

Permalink
fix(popover): visible error (#1603)
Browse files Browse the repository at this point in the history
当content被关闭时,无法触发onMouseLeave 导致 父子组件visible不一致
  • Loading branch information
berber1016 committed Dec 3, 2021
1 parent a40bddc commit 91fa0d2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/popover/Popover.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useMemo, useCallback, useRef, useLayoutEffect } from 'react';
import React, { useState, useMemo, useCallback, useRef, useLayoutEffect, useEffect } from 'react';
import classNames from 'classnames';
import { debounce, isFunction } from 'lodash';
import { usePopper } from 'react-popper';
Expand Down Expand Up @@ -41,6 +41,10 @@ const Popover = (props: PopoverProps) => {
const [popperElement, setPopperElement] = useState<null | HTMLElement>(null);
const arrowElement = useRef<HTMLDivElement | null>(null);

useEffect(() => {
if (!visible) overContentRef.current = false;
}, [visible]);

const contentCls = useMemo(
() =>
classNames(
Expand Down

1 comment on commit 91fa0d2

@vercel
Copy link

@vercel vercel bot commented on 91fa0d2 Dec 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.