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

Prevent click outside for radix select inside inspector modal #6591

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

ruggi
Copy link
Contributor

@ruggi ruggi commented Oct 25, 2024

Problem:

RadixSelect components inside inspector modals don't actually respect their click outside handling, causing the modal to close down, moving focus back to whatever is behind, e.g. the canvas.

Fix:

The problem is that this happens because RadixSelects are rendered in their own portal, which interferes with the one created by the inspector modal.
I tried multiple ways, e.g. setting the onPointerDownOutside prop of the Radix component itself, but it does not work. The only thing that seems to be working is adding an overlay div in the component's content itself, which will handle closing the select gracefully (see the recording please).

Before After
Kapture 2024-10-25 at 16 05 24 Kapture 2024-10-25 at 16 04 21

Fixes #6590

Copy link
Contributor

github-actions bot commented Oct 25, 2024

Try me

Copy link

relativeci bot commented Oct 25, 2024

#14931 Bundle Size — 57.98MiB (~+0.01%).

13cad3d(current) vs 916e8b9 master#14928(baseline)

Warning

Bundle contains 70 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#14931
     Baseline
#14928
Regression  Initial JS 40.96MiB(~+0.01%) 40.96MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 18% 0%
No change  Chunks 20 20
No change  Assets 22 22
No change  Modules 4152 4152
No change  Duplicate Modules 213 213
No change  Duplicate Code 27.33% 27.33%
No change  Packages 477 477
No change  Duplicate Packages 70 70
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#14931
     Baseline
#14928
Regression  JS 57.97MiB (~+0.01%) 57.97MiB
Improvement  HTML 7.37KiB (-0.25%) 7.39KiB

Bundle analysis reportBranch fix/prevent-click-outside-react-...Project dashboard


Generated by RelativeCIDocumentationReport issue

@ruggi ruggi merged commit bcbd2e5 into master Oct 29, 2024
16 checks passed
@ruggi ruggi deleted the fix/prevent-click-outside-react-select branch October 29, 2024 09:44
liady pushed a commit that referenced this pull request Dec 13, 2024
**Problem:**

`RadixSelect` components inside inspector modals don't actually respect
their click outside handling, causing the _modal_ to close down, moving
focus back to whatever is behind, e.g. the canvas.

**Fix:**

The problem is that this happens because RadixSelects are rendered in
their own portal, which interferes with the one created by the inspector
modal.
I tried multiple ways, e.g. setting the `onPointerDownOutside` prop of
the Radix component itself, but it does not work. The _only_ thing that
seems to be working is adding an overlay div in the component's content
itself, which will handle closing the select gracefully (see the
recording please).

| Before | After |
|----------|---------|
| ![Kapture 2024-10-25 at 16 05
24](https://github.com/user-attachments/assets/3fb3a149-31e6-4ba4-85fc-673544d82f46)
| ![Kapture 2024-10-25 at 16 04
21](https://github.com/user-attachments/assets/50bf89d0-02a3-4deb-909b-6872897e2c57)
|

Fixes #6590
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Radix select does not respect click outside
3 participants