Skip to content

Autocomplete: option for disabling auto-focus of search field? #8160

Open
@jeffijoe

Description

@jeffijoe

Provide a general summary of the feature here

I'd like a prop for Autocomplete that turns off the automatic focusing of the search field when interacting with items.

🤔 Expected Behavior?

When the new prop disableAutoFocusOnItemInteraction (name tbd 😅 ) is true, interacting with items in the list will not trigger focus on the search field. However, if the search field is already focused, then the focus will be maintained.

😯 Current Behavior

Currently, any interaction with the items triggers focus on the search field. This causes the soft keyboard on mobile devices to appear, which is unexpected.

💁 Possible Solution

No response

🔦 Context

I'm using autocomplete inside of a modal. Since I'm animating the modal in with a slide-in animation using motion/react, the auto-focus behavior breaks the visual viewport adjustment that react-aria makes to fit the dialog within the viewport. Additionally, with auto-focus, the keyboard cannot be dismissed on iOS (this appears to be a general bug).

focus-issue-encoded.mp4

As a workaround, I decided to disable autoFocus on the search field for the autocomplete. However, now, when the user interacts with an item that is halfway down the visible viewport, the keyboard opens and covers the item that the user interacted with.

autofocus-autocomplete-encoded.mp4

💻 Examples

No response

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    🩺 To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions