Skip to content

Commit 5570eba

Browse files
authored
Merge pull request #29663 from parasharrajat/revert-29251-fix/issue-29159
Revert "fix: remove unnecessary dependency"
2 parents 79ade92 + 0912b7f commit 5570eba

File tree

1 file changed

+5
-2
lines changed
  • src/components/PopoverWithoutOverlay

1 file changed

+5
-2
lines changed

src/components/PopoverWithoutOverlay/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import styles from '../../styles/styles';
88
import * as StyleUtils from '../../styles/StyleUtils';
99
import getModalStyles from '../../styles/getModalStyles';
1010
import withWindowDimensions from '../withWindowDimensions';
11+
import usePrevious from '../../hooks/usePrevious';
1112

1213
function Popover(props) {
1314
const {onOpen, close} = React.useContext(PopoverContext);
@@ -24,6 +25,8 @@ function Popover(props) {
2425
props.outerStyle,
2526
);
2627

28+
const prevIsVisible = usePrevious(props.isVisible);
29+
2730
React.useEffect(() => {
2831
if (props.isVisible) {
2932
props.onModalShow();
@@ -40,7 +43,7 @@ function Popover(props) {
4043
Modal.willAlertModalBecomeVisible(props.isVisible);
4144

4245
// We prevent setting closeModal function to null when the component is invisible the first time it is rendered
43-
if (!firstRenderRef.current || !props.isVisible) {
46+
if (prevIsVisible === props.isVisible && (!firstRenderRef.current || !props.isVisible)) {
4447
firstRenderRef.current = false;
4548
return;
4649
}
@@ -49,7 +52,7 @@ function Popover(props) {
4952

5053
// We want this effect to run strictly ONLY when isVisible prop changes
5154
// eslint-disable-next-line react-hooks/exhaustive-deps
52-
}, [props.isVisible]);
55+
}, [props.isVisible, prevIsVisible]);
5356

5457
if (!props.isVisible) {
5558
return null;

0 commit comments

Comments
 (0)