Skip to content

fix(VAutocomplete): keyboard navigation with virtual scroll items#22778

Closed
hellozzm wants to merge 1 commit intovuetifyjs:masterfrom
hellozzm:fix/issue-22770
Closed

fix(VAutocomplete): keyboard navigation with virtual scroll items#22778
hellozzm wants to merge 1 commit intovuetifyjs:masterfrom
hellozzm:fix/issue-22770

Conversation

@hellozzm
Copy link
Copy Markdown

Summary

When using VAutocomplete with many items (e.g., 100+), keyboard navigation with ArrowUp/ArrowDown only works through the currently visible items in the virtual scroll. This is because VList's focusChild function filters out non-rendered DOM elements via offsetParent check, so items outside the viewport are not navigable.

This fix intercepts ArrowUp/ArrowDown keydown events in the menu handler, tracks the current virtual list index, uses VVirtualScroll.scrollToIndex() to scroll to the target item, and then focuses it.

Playground Markup

<template>
  <v-app>
    <v-container style="max-width: 400px">
      <v-autocomplete
        label="Select an item"
        :items="items"
        density="comfortable"
      ></v-autocomplete>
    </v-container>
  </v-app>
</template>

<script setup>
  const items = Array.from({ length: 100 }, (_, i) => `Item ${i + 1}`)
</script>

Testing

  1. Open the playground above
  2. Click on the autocomplete to open the dropdown
  3. Press ArrowDown repeatedly - should navigate through ALL 100 items, scrolling as needed
  4. Press ArrowUp at the first item - should wrap to the last item
  5. Press ArrowDown at the last item - should wrap to the first item
  6. Expected: smooth navigation through all items with proper scroll behavior
  7. Before fix: navigation would only cycle through visible items (~10-15)

Fixes #22770

When using VAutocomplete with many items and VVirtualScroll, keyboard
navigation (ArrowUp/ArrowDown) only worked through visible items because
VList's focusChild filters out non-rendered elements. This fix intercepts
arrow key events in the menu and uses VVirtualScroll's scrollToIndex to
properly navigate through all items.

Fixes vuetifyjs#22770
@J-Sek
Copy link
Copy Markdown
Contributor

J-Sek commented Mar 29, 2026

Please stop posting AI slop. There is nothing of value in this PR

@J-Sek J-Sek closed this Mar 29, 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.

[Bug Report][4.0.4] VAutocomplete keyboard navigation broken with many items

2 participants