Skip to content

Comments

Auto-focus search input on modal open#40

Merged
brunoborges merged 2 commits intomainfrom
copilot/focus-search-input-on-open
Feb 18, 2026
Merged

Auto-focus search input on modal open#40
brunoborges merged 2 commits intomainfrom
copilot/focus-search-input-on-open

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

Search modal opens but input field requires an extra click before users can type.

Changes

The input.focus() call was executing synchronously while the overlay transitioned from visibility: hidden to visibility: visible (200ms CSS transition). Elements with visibility: hidden cannot receive focus.

Wrapped focus call in double requestAnimationFrame() to defer until after the browser completes the visibility transition:

const openSearch = () => {
  overlay.classList.add('active');
  if (input) {
    input.value = '';
    // Double requestAnimationFrame ensures focus after visibility transition
    requestAnimationFrame(() => {
      requestAnimationFrame(() => {
        input.focus();
      });
    });
  }
  renderResults('');
};

This applies to both the ⌘K keyboard shortcut and clicking the "Search..." button.

Screenshot

Search modal now receives immediate focus - users can start typing without clicking:

Search with immediate typing

Original prompt

This section details on the original issue you should resolve

<issue_title>searchInput should be focused when search opens</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add focus to search input when search opens Auto-focus search input on modal open Feb 18, 2026
@brunoborges brunoborges marked this pull request as ready for review February 18, 2026 18:59
@brunoborges brunoborges merged commit db12452 into main Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

searchInput should be focused when search opens

2 participants