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

[BUG] - Autocomplete don't focus on input #3203

Closed
iPagar opened this issue Jun 6, 2024 · 15 comments · Fixed by #3311
Closed

[BUG] - Autocomplete don't focus on input #3203

iPagar opened this issue Jun 6, 2024 · 15 comments · Fixed by #3311
Assignees
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working

Comments

@iPagar
Copy link

iPagar commented Jun 6, 2024

NextUI Version

2.4.1

Describe the bug

When I click on autocomplete it should focus on input

Your Example Website or App

https://codesandbox.io/p/sandbox/objective-nash-lff3pt

Steps to Reproduce the Bug or Issue

  1. Copy code from https://nextui.org/docs/components/autocomplete#usage
  2. Click on autocomplete
  3. Input is not focused

Expected behavior

Input has to be focused as it shown at https://nextui.org/docs/components/autocomplete#usage

Screenshots or Videos

No response

Operating System Version

macOS

Browser

Chrome

Copy link

linear bot commented Jun 6, 2024

@wingkwong
Copy link
Member

seems it looks fine in local storybook but not in app.

@wingkwong wingkwong added 🐛 Type: Bug Something isn't working 📦 Scope : Components Related to the components labels Jun 7, 2024
@MarcoRodasW
Copy link

Same issue for me, i have autocompletes everywhere in the app 🥲

@MarcoRodasW
Copy link

@wingkwong Any temporary solution until it is fixed?

@daniel-esserweb
Copy link

This still not fixed in v2.4.2

@MarcoRodasW
Copy link

@daniel-esserweb Noup, I switched to version 2.2.9 until they fix it

@daniel-esserweb
Copy link

@daniel-esserweb Noup, I switched to version 2.2.9 until they fix it

I dont understand why, in the documentation is working since 2.4.0 i think, but in the application hasn't worked yet

@MarcoRodasW
Copy link

@daniel-esserweb Me neither, I tried different versions and only 2.29 and below worked for me.

@cnfw
Copy link

cnfw commented Jun 17, 2024

I do this temporary workaround to get around the autofocus issue, but it would only work for mouse clicks - keyboard users still need to be considered.

<Autocomplete
    onClick={(event) =>
        // @ts-expect-error the input doesn't automatically focus
        event.target.focus()
    }

>
// ...
</Autocomplete>

@kuri-sun
Copy link
Contributor

kuri-sun commented Jun 17, 2024

@iPagar Thanks for the report!
Speaking of which, I also found a related bug for Autocomplete component so I will put it down here as well.
When an user try to remove chars from the input, the input will freeze 😞 (In the video, it's really hard to tell but I was pressing the key multiple times.)
These issues seem like happening only on local env(dev env) & sandbox env.
I will also try to take a look at these! Thanks again for reporting this issue! 👍

Screen.Recording.2024-06-18.at.1.09.58.AM.mov

@cedoromal
Copy link

I think it's the same issue as this one: #3124

It's possible that the focus on input is lost right after the selection is opened. I added a comment there for steps to reproduce the focus loss on input.

@daniel-esserweb
Copy link

Just a curiosity, it is very buggy in local development but in production it works fine

@wingkwong
Copy link
Member

@daniel-esserweb it is due to react strict mode, which only happens in local development.

@MarcoRodasW
Copy link

@daniel-esserweb Does not work in production as well

@wingkwong
Copy link
Member

@MarcoRodasW are you using 2.4.2? also can you share a minimal reproducible project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants