Combobox: mounting open moves focus into the input even without autoFocus

Open
#3,715 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
69/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start by locating the combobox state machine and its input focus handling, then trace how mounting with defaultOpen differs from opening by click or key. Reproduce with autoFocus off and check document.activeElement; done means mount leaves focus in place while user-triggered opening still focuses the input.

Written by the indexing model from the issue text.

Description

🐛 Bug report

A combobox that mounts open moves focus into its input, even with autoFocus off. With defaultOpen, the page loads with focus inside the combobox instead of at the top.

💥 Steps to reproduce

  1. Render a combobox with defaultOpen and without autoFocus, below some other focusable content.
  2. Load the page.
  3. Check document.activeElement. It's the combobox input.

💻 Link to reproduction

No sandbox yet. Any combobox example with defaultOpen shows it.

🧐 Expected behavior

Focus only moves on mount when autoFocus is set. Opening from a click or a key still focuses the input, as it does today.

🌍 System information

Software Version(s)
Zag Version 1.49.0, and 2.0.0-next.4
Browser Any
Operating System Any

🧢 Your Company/Team

IQ Industries

Dominant language
TypeScript
Stars
5.3k
Forks
320
Avg merge
1d 22h
Merged PRs (30d)
60

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from chakra-ui/zag

All issues in chakra-ui/zag

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.