Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/react-core/src/helpers/Popper/Popper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
const [popperContent, setPopperContent] = React.useState(null);
const [ready, setReady] = React.useState(false);
const [opacity, setOpacity] = React.useState(0);
const [display, setDisplay] = React.useState('none');
const [internalIsVisible, setInternalIsVisible] = React.useState(isVisible);
const transitionTimerRef = React.useRef(null);
const showTimerRef = React.useRef(null);
Expand Down Expand Up @@ -443,6 +444,12 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
]
});

React.useEffect(() => {
if (internalIsVisible) {
forceUpdate && forceUpdate();
}
}, [internalIsVisible]);

/** We want to forceUpdate only when a tooltip's content is dynamically updated.
* TODO: Investigate into 3rd party libraries for a less limited/specific solution
*/
Expand Down Expand Up @@ -475,6 +482,7 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
showTimerRef.current = setTimeout(() => {
setInternalIsVisible(true);
setOpacity(1);
setDisplay('');
onShown();
}, entryDelay);
};
Expand All @@ -486,6 +494,7 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
setOpacity(0);
transitionTimerRef.current = setTimeout(() => {
setInternalIsVisible(false);
setDisplay('none');
onHidden();
}, animationDuration);
}, exitDelay);
Expand Down Expand Up @@ -516,6 +525,7 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
...popperStyles.popper,
zIndex,
opacity,
display,
transition: getOpacityTransition(animationDuration)
},
...attributes.popper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { render, screen, waitForElementToBeRemoved } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { CheckboxSelect } from '../CheckboxSelect';
import styles from '@patternfly/react-styles/css/components/Badge/badge';
Expand Down Expand Up @@ -137,8 +137,6 @@ test('toggles the select menu when the toggle button is clicked', async () => {

await user.click(toggleButton);

await waitForElementToBeRemoved(() => screen.queryByRole('menu'));

expect(screen.queryByRole('menu')).not.toBeInTheDocument();
});

Expand Down