Skip to content

[Bug] Clicking AutocompleteCancel when input unfocused doesn't refresh dropdown items #2988

Closed

Description

@vincerubinetti

Vue 3
Reka UI v2.10.5

Minimal reproduction: https://stackblitz.com/edit/vue-3-composition-api-demo-dtgwudap?file=package.json

code
<script setup>
import { ref } from "vue";
import {
  AutocompleteAnchor,
  AutocompleteCancel,
  AutocompleteContent,
  AutocompleteInput,
  AutocompleteItem,
  AutocompletePortal,
  AutocompleteRoot,
  AutocompleteViewport,
} from "reka-ui";

const options = ["Apple", "Banana", "Cherry"];
const model = ref("");
</script>

<template>
  <AutocompleteRoot v-model="model" :openOnClick="true" :openOnFocus="true">
    <AutocompleteAnchor>
      <AutocompleteInput placeholder="Search..." />
      <AutocompleteCancel>X</AutocompleteCancel>
    </AutocompleteAnchor>

    <AutocompletePortal>
      <AutocompleteContent>
        <AutocompleteViewport>
          <AutocompleteItem
            v-for="option in options"
            :key="option"
            :value="option"
          >
            {{ option }}
          </AutocompleteItem>
        </AutocompleteViewport>
      </AutocompleteContent>
    </AutocompletePortal>
  </AutocompleteRoot>
</template>

Steps to reproduce:

  1. Click textbox to open dropdown.
  2. Select an item, OR type something and click off to blur.
  3. With dropdown closed, click X button.
  4. Textbox is set to blank, but items are still filtered by previous textbox contents.
Claude's opinion on why this happens

This happens because ComboboxCancel's click handler clears filterSearch, clears the DOM input value, calls inputElement.focus(), and only then clears modelValue. Since the input was previously blurred, that .focus() call synchronously fires a real focus event, which (for openOnFocus) triggers onOpenChange(true). In both ComboboxRoot and AutocompleteRoot, onOpenChange(true) re-stamps filterSearch from the current modelValue before yielding at await nextTick() — but at that point modelValue hasn't been cleared yet (that happens in the line after .focus() returns), so filterSearch gets set back to the stale text and is never corrected afterward. The fix should be to clear modelValue before calling .focus() in the Cancel handler, so that when the focus-triggered re-open reads modelValue, it reads the already-cleared value.

Activity

  1. changed the title [-][Bug] AutocompleteCancel doesn't refresh dropdown items when clicked[/-] [+][Bug] Clicking `AutocompleteCancel` when input unfocused doesn't refresh dropdown items[/+] on Oct 4, 2026
  2. added a commit that references this issue on Oct 5, 2026
    94965ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions