Skip to content

Likely race in Combobox enter handling #2942

@david-crespo

Description

@david-crespo

There is probably a race in Headless's handling of the enter keypress in the combobox. This is low-priority because human users can't interact fast enough to hit the race — we only see it in CI because of Playwright.

Claude's proposed solution doesn't work because we actually need that event to bubble and be turned by Headless into a form submission when the combobox list is closed. We are reworking this form at some point, which will probably eliminate the immediate problem, but if there's a bug inside Combobox we're just kicking the can if we don't fix it.

onKeyDown={(e) => {
// If the caller is using onEnter to override enter behavior, preventDefault
// in order to prevent the containing form from being submitted too. We don't
// need to do this when the combobox is open because that enter keypress is
// already handled internally (selects the highlighted item). So we only do
// this when the combobox is closed.
if (e.key === 'Enter' && onEnter && !open) {
e.preventDefault()
onEnter(e)
}
}}

image

Originally posted by @david-crespo in #2941 (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