Skip to content
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

Combination of menuPortalTarget and menuShouldBlockScroll causes click on document #5020

Open
AdrianMrn opened this issue Jan 20, 2022 · 1 comment
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet

Comments

@AdrianMrn
Copy link

AdrianMrn commented Jan 20, 2022

Are you reporting a bug or runtime error?

Bug

I set up the dev server with the docs on my machine to see if this was my setup, but it happens there too.

When creating a Select component with menuPortalTarget={document.body} and menuShouldBlockScroll={true} and opening the select, a click event is propagated to the document, even when I've wrapped the select component in a div with onClick={e => e.stopPropagation()}.

This would be logical when clicking on the menu itself (which is rendered in a portal so outside of my stopPropagation), but not when clicking on the input itself, which is definitely still a child of the propagation-stopping div.

I need the combination of both of these props to fix other issues in my app (mainly z-index issues and this one: #4088)

In my app, I'm rendering the select in a dropdown that listens to a click event on document to close the dropdown, opening the select instantly closes the dropdown because of this bug.

I've narrowed it down to this fixed div being rendered over the screen (which I believe is all menuShouldBlockScroll does):

{lockEnabled && (
<div
onClick={blurSelectInput}
css={{ position: 'fixed', left: 0, bottom: 0, right: 0, top: 0 }}
/>
)}

Even when wrapping the ScrollManager in a div that stops propagation of the click event, this still happens.

The click event has a srcElement of body for some reason. Could this mean this is being caused by a strange combination of a mouseUp and mouseDown event being triggered on 2 separate elements?

Any idea what I could do differently to get this to work, or any pointers to how I could better debug this?

@AdrianMrn AdrianMrn added the issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet label Jan 20, 2022
@Rall3n
Copy link
Collaborator

Rall3n commented Feb 8, 2022

Hello @AdrianMrn,

would be so kind and provide a minimal reproducible example using CodeSandbox as requested in the issue template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet
Projects
None yet
Development

No branches or pull requests

2 participants