Popover + Portal inside Modal isn't clickable
See original GitHub issueDescription
Rendering popover in a Portal inside a Modal prevents users from interacting with the Popover. Portals are usually needed when using <Modal scrollBehavior="inside">
.
Link to Reproduction
https://codesandbox.io/s/chakra-modal-popover-portal-lfeep?file=/src/index.tsx
Steps to reproduce
- Visit codesandbox
- Click on “Open w/ inline popover” to see expected behavior
- Click on “Open w/ Portal popover” to see issue
Chakra UI Version
1.6.6
Browser
Chrome 92
Operating System
- macOS
- Windows
- Linux
Additional Information
Couple workarounds:
- to display the Popover over the ModalOverlay, you can set
<ChakraProvider portalZIndex={5000}>
- to enable interaction of the Popover inside the Portal, you can set
<Modal focusTrap={false}>
Here’s what it looks like in our app:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Boostrap popover not sticking inside modal - Stack Overflow
The problem is when I use popover outside the modal, it functions as expected, when you scroll down, popover it sticking to its...
Read more >Popover - Reakit
Popover. Popover is a non-modal dialog that floats around its disclosure. It's commonly used for displaying additional rich content on top of something....
Read more >4 reasons your z-index isn't working (and how to fix it)
This article will explain in detail four of the most common reasons that z-index isn't working for you, and exactly how you can...
Read more >Creating An Outside Focus And Click Handler React Component
In this article, we'll look at how to create an outside focus and click handler with React. We will recreate an open source...
Read more >React Popover component - Material UI - MUI
Things to know when using the Popover component: The component is built on top of the Modal component. The scroll and click away...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not stale
Reopened and labelled bug not sure it’s really a bug though. It could be a feature. This is now the third such request - two from Github and one from the Discord community for something I’d consider an edge case. Perhaps that’s why it wasn’t included with
Popover
.Triage: When you open a
Popover
in aPortal
from aModal
andtrapFocus
is true, focus is kept within the modal making selection of any fields in thePopover
impossible. Chakra uses react-focus-lock to trap the focus. The library does support Portals, but that feature is not included within Chakra. In order to allow access to the Popover, one of the three ways provided in the React Focus Lock library needs to be implemented with Chakra.This CodeSandbox has a rough solution using
group
. I’d have to look into thegroup
prop more to fully understand what it is doing.