Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
YektaRoustaei wants to merge 1 commit into tailwindlabs:main
base: main
Choose a base branch
Loading
from YektaRoustaei:fix/combobox-blur-autoselect

Conversation

@YektaRoustaei
Copy link

@YektaRoustaei YektaRoustaei commented Aug 3, 2025

🐛 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
edited
Loading

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
edited
Loading

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).

Copy link

Is this still something that's being actively worked on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@mochetts mochetts mochetts left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /