Skip to content

Conversation

@david-crespo
Copy link
Collaborator

@david-crespo david-crespo commented Jan 21, 2026

Closes #3012

Was curious how Claude would handle this. It cost $1.31. It did not get it until I explained that in the video, we do not see the list options close, we only see the typed-in query disappear. I've confirmed by hand that the fix does appear to work.

Claude's explanation:

The onClose callback in the Combobox component unconditionally cleared the typed query. When the browser tab loses focus, Headless UI fires onClose (because the input blurs), which cleared the user's in-progress filter text.

The fix checks document.hasFocus() before clearing. When the document doesn't have focus (user switched tabs/windows), we preserve the query. When the user deliberately closes the dropdown (clicks outside, presses Escape, selects an item), the query is cleared as before.

Just putting this up to look into more later. I want to look into this behavior of Headless, calling onClose on blur. I don't understand why we don't see the options list close too. I'm also skeptical that adding 4 seconds worth of tests to the e2e suite is worth it for this one thing — maybe we do need something faster than playwright for component-level tests now that they're so cheap to write. We could have hundreds of them.

@vercel
Copy link

vercel bot commented Jan 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
console Ready Ready Preview Jan 21, 2026 11:01pm

Request Review

setTimeout(() => {
document.hasFocus = originalHasFocus
}, 50)
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is really contrived, but it does fail without the fix in exactly the way you'd expect, and it passes with the fix.

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.

Page losing focus discards state in dropdown

2 participants