Skip to content

fix(vue): prevent auto-selecting option on input blur when no user input #3772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

YektaRoustaei
Copy link

🐛 Bug Fix

This PR resolves issue #3771, where the Vue <Combobox> would auto-select the active option (typically the first one) when the input was blurred — even if the user didn’t select anything or type.

✅ Changes

  • Updated handleBlur logic to prevent auto-selection unless:
    • The user manually triggered the combobox (not just by focusing), and
    • There is non-empty user input.
  • Prevents unintended value commits when blurring after opening the dropdown via tab/focus.
  • Ensures nullable comboboxes properly clear the value if input is cleared.

🧪 Tests Added

  • should not auto-select when input was focused and blurred without typing
  • should not auto-select the active option when the combobox input is blurred

These regression tests ensure no value is selected unintentionally during blur.

🧠 Context

This behavior was correct in v1.7.13, but regressed in later versions. This change restores expected UX where blur does not imply selection unless explicitly intended.


Let me know if anything needs clarification. Happy to iterate on feedback!

Copy link

vercel bot commented Aug 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 3, 2025 1:58pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 3, 2025 1:58pm

const hasUserInput = inputValue.trim().length > 0

if (hasUserInput) {
api.selectActiveOption()
Copy link

@mochetts mochetts Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think blurring the input should ever select an option.
See how shadcn works:

https://ui.shadcn.com/docs/components/combobox

That's what i would expect from a combobox (blurring cancels edition).

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.

2 participants