-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opening overlay with timeout causes unexpected behavior during testing components with MultiSelect #7196
Comments
Actually, this doesn’t only occur when the React.useEffect(() => {
if (props.overlayVisible === true) {
setTimeout(() => show(), 100);
} else if (props.overlayVisible === false && overlayRef.current.isVisible) {
setTimeout(() => hide(), 100);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [props.overlayVisible]); (I'm also assuming that the timeout is not needed to hide the overlay🤔) I can add this to my PR, but I’d like some time to think of a more effective approach without |
no problem let me know when your PR is ready and I will review it! |
@melloware I found the solution! The issue was simpler than I initially thought😅 The problem was that |
Describe the bug
The issue is caused by
setTimeout
inuseEffect
to show or hide the overlay panel with a delay (lines of code). This forces you to wait for the timeout in tests after mounting components withMultiSelect
. Without this wait, the second option won’t be selected, and the test will fail🤷♂️I’m not sure why this delay was added, but after removing it and testing locally, everything worked fine.
Reproducer
https://stackblitz.com/edit/dxmu22?file=src%2FApp.test.jsx
System Information
Steps to reproduce the behavior
App.test.jsx
filenpm run test
scriptwait
, and you’ll see the second option won’t be selected, leading to the following error:Expected behavior
The
MultiSelect
component should allow selecting multiple options without needing to wait for a timeout in tests. All options should be selectable as expected after opening the dropdown, and the component should behave consistently.The text was updated successfully, but these errors were encountered: