-
Notifications
You must be signed in to change notification settings - Fork 810
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
Modal does not close after first click on the overlay #958
Comments
I'm having the same issue too. I have to click on the overlay twice if you click on the modal content once for some weird reason. |
If you look at the source code, it seems like it was done on purpose.
No idea why though, I hope a maintainer is reading this and provide some input as to why. |
@diasbruno hey, just wondering if you can input on my previous comment, thanks :) |
Sure, @jacktan165. Unfortunately, this is weird...the code only fails on chrome. Can you, @VladBrok and @jacktan165, check if this code works on older versions of chrome? |
No, sorry, I don't have older chrome versions |
@diasbruno I'm currently working on a project with a different codebase but it still have this issue. I tried out that codesandbox @VladBrok has linked on Edge and Firefox, as well as an older Chrome version 79, it's still the same issue. I don't think it's the browser issue, but specifically related to that variable |
It's quiet strange because I don't recall anyone changing Currently, I don't have much time to work on this project, but it should be a really easy debug to do...so, let me know if you need any help with this. Just ping me. Good luck! |
This piece is a 3 state |
To better debug this, you can use run the examples and set breakpoints on the handles...this way you can see the internal state in the moment of the event. Are you using react >16? |
Oops sorry! Yeah I'm using React v17 atm. I'm currently debugging my own project atm, and it looks I might be able to figure out the root cause! I have a navigation tab inside the modal, but when I click on one of the navigation tab, it does not trigger |
Ah, it did trigger |
Try to prevent the event propagation on your component... |
I fixed it! I already have |
Your component can go out of the modal's content area (over the overlay)? |
No it can't. I have this annoying requirement where I have a button on top of a clickable card. Initially I set |
it's right, but the overlay element do has some propogation problem. my solution: const renderOverlay = ({ onClick, ...rest }: any, children: ReactNode) => {
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
e.stopPropagation();
onClick(e);
};
return (
<div {...rest} onClick={handleClick}>
{children}
</div>
);
}; <RcModal
className={cx(style.commonModal, className)}
isOpen={on}
overlayElement={renderOverlay}>
...
</RcModal> |
Summary:
Modal ignores the first click on the overlay and closes only after a second click
Steps to reproduce:
Expected behavior:
Modal closes after the first click on the overlay
Link to example of issue:
https://codesandbox.io/s/heuristic-goodall-n25g2w?file=/src/App.js
Additional notes:
I've noticed that if I set 'top: 40px' to the 'modal' class, everything works as expected
The text was updated successfully, but these errors were encountered: