geist-org / geist-ui

A design system for building modern websites and applications.
https://geist-ui.dev
MIT License
4.35k stars 335 forks source link

Select, ButtonDropdown dropdowns don't react to click outside when placed in Modal #509

Closed rihardsgravis closed 3 years ago

rihardsgravis commented 3 years ago

Bug report 🐞

Select, ButtonDropdown components don't close on click outside when placed in a Modal component.

Version & Environment

Expected Behaviour

Select, ButtonDropdown dropdown menus should close when user clicks inside the modal window area.

Actual results (or Errors)

The dropdown menus stay open. Reproduction example - https://codesandbox.io/s/crimson-architecture-9p391

rihardsgravis commented 3 years ago

Looks like the Backdrop component's childrenClickHandler causes this by preventing the click event at: https://github.com/geist-org/react/blob/18c1afbc14d8d7ba7c6352d6a0084211d29d6f07/components/shared/backdrop.tsx#L30

Removing the event.stopPropagation()resolves the issue and the Backdrop continues to work as expected, at least for the Modal component. I could create a PR, but not sure of the side effects 😅

unix commented 3 years ago

I tried the online example and click on the blank part of the Modal is able to make the Select close up, am I missing anything?

rihardsgravis commented 3 years ago

I tried the online example and click on the blank part of the Modal is able to make the Select close up, am I missing anything?

Ah, could not understand why it's working on CodeSandbox and not for me locally 😅 The bug is actually reproducible with React v17 - https://codesandbox.io/s/determined-poincare-085kw

unix commented 3 years ago

I see. It seems that this is caused by the event system upgrade of react17. I will add a compatible one to fix it.