Closed egoist closed 11 months ago
I have the same issue. A select in a dialog, which I cannot click on. When inspecting the dom, data-state="closed"
flashes but it is closed
again. If I spam the select trigger, for a microsecond I can see "open"`.
Edit: While I'm here, keyboard navigation is not working. This is on Chrome "Version 119.0.6045.159 (Official Build) (arm64)". Do you have this issue, @egoist?
@ibrahimbutt yes basically it gets instantly closed when it’s opened , although I only encountered this in safari
@egoist @ibrahimbutt
Thanks for bringing this to our attention. We will have a look shortly.
Please use the described workaround without the Portal
for now.
@cschroeter I have wrapped it in a Portal
, but have the same result. Snippet:
<Portal>
<ArkSelect.Positioner>
<ArkSelect.Content className={classes.content}>
{items.map((item) => (
<ArkSelect.Item key={item} item={item} className={classes.item}>
<ArkSelect.ItemText>{item}</ArkSelect.ItemText>
<ArkSelect.ItemIndicator></ArkSelect.ItemIndicator>
</ArkSelect.Item>
))}
</ArkSelect.Content>
</ArkSelect.Positioner>
</Portal>
Without the portal ;)
Weirdly this also happens when Select is used outside Dialog and without Portal, in this case adding a Portal makes it work properly, reproduced in Chrome, the log suggests it's instantly closed after being opened, I might add a repro for this later as well.
Here's a repro for a Controlled Select Component (not using Dialog): https://stackblitz.com/edit/stackblitz-starters-p4zsyy?file=src%2FApp.tsx
It works fine on Safari but not Chrome:
safari | chrome |
---|---|
When I tap (using macbook touchpad) it doesn't work, but it works normally with mouse click.
@egoist
I was unable to replicate the issue with a standalone Select
component in any major browser.
However, the issue you're encountering with a Select
inside a Dialog
is related to focus trapping. When a Dialog
is rendered within a Portal
, the focus remains confined to that portalled Dialog
. Attempting to render another Portal
within this setup disrupts the focus trap, which likely leads to the problem you initially described.
There are a couple of ways to address this:
Select
within a Portal
(this is the recommended approach).trapFocus
on the Dialog
(note: this may impact accessibility).
Description
This is a Safari only issue, Select component does not work when used in Dialog. It doesn't open when I click it.
Link to Reproduction (or Detailed Explanation)
https://stackblitz.com/edit/stackblitz-starters-6fdhv2?file=src%2FApp.tsx
Steps to Reproduce
This code in the repro is just the default example from the docs.
Note that it only works if you do not wrap
Select.Positioner
with aPortal
.Ark UI Version
1.1.0
Framework
Browser
Safari 17.1 (19616.2.9.11.7)
Additional Information