-
Notifications
You must be signed in to change notification settings - Fork 331
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
Cannot programmatically open detached autocomplete if openOnFocus is false #843
Comments
In DocSearch the modal renders only when it's explicitly opened: I'm not saying that's per se the best solution, and what you're describing here does seem like a bug, I'd just like to offer a different workflow that avoids this issue |
It does look like a bug. The problem persists in 1.5.0 so it doesn't look like a regression introduced in 1.5.1. I will investigate. |
I've looked into it, this is indeed a bug. Here's what happens:
This is why you might briefly see the modal opening then closing—the modal is opening as requested, but the side-effects of focusing the input closes it. You can observe a similar behavior on mobile when The behavior of the state reducer is likely correct, this issue should be fixed in at the detached mode level, in Note that "just" removing this internal focus behavior, or making it depend on |
@Haroenv The DocSearch example uses @cmfcmf What's your use case for setting For example, if the goal is to avoid an empty query, you can add a check before returning sources: https://codesandbox.io/s/charming-jasper-4o1ix?file=/app.tsx:993-1049 |
I’ve just run into this. In my case I’m aiming not to have an inline search field, just a button that opens up the detached search view with the field selected (on desktop and mobile). It’s not a huge problem to enable
|
@domstubbs Yes, this is a problem because in this scenario, .aa-PanelLayout:empty {
display: none;
} |
@sarahdayan I did implement a CSS workaround but yours is neater. Thanks! |
I didn't remember initially, but I think it was mainly for the reason @domstubbs brought up. |
I believe we have a similar issue and @sarahdayan we would appreciate your advice on it! |
Hey @atanasStoyanov, could you share a minimal reproduction so we can debug? You can use this starter template to help you get started. |
Hey @sarahdayan thanks for your willingness to help. We found that the issue comes from our implementation. Long story short the component has been re-rendered too many times because of scroll event listener and that was causing the detached modal being re-rendered as well and respectively closed. Once we prevented those re-renders it got fixed and now works properly. Thank you! |
What's a CSS solution, if I have and need |
Description
The autocomplete does not open when calling
api.setIsOpen(true)
ifdetachedMediaQuery
=""
andopenOnFocus
=false
.Reproduction
https://codesandbox.io/s/magical-tree-499cg?file=/app.tsx
Steps
app.tsx
)Expected behavior
The autocomplete should open when calling
api.setIsOpen(true);
.Environment
The text was updated successfully, but these errors were encountered: