react: Popups opened from `onClick` handlers get blocked by browsers
Which doesn’t happen when I use addEventListener to bind 'click' to a function that opens a popup.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 17 (8 by maintainers)
In a more concise manner: avoid network (or other async) calls between the click event and the popup creation!
I was getting the url from the back-end, which made the new tab opening being blocked. Switching the source of the URL to the front-end or doing a
window.location.href = url;(open in same window) seems to do the trick.@dancherb Make a backend endpoint that HTTP-redirects (if URL is quick to get) or JS-redirects (print the JS at the end of the body, flush some spinner from the server immediately so that the “downloading” page doesn’t feel empty) to the correct URL after the URL is ready. Open that endpoint in a new tab immediately, let it hang there.