Skip to content

useCombobox hook isOpen state "regression" starting from v9.2.0 ? #1680

@ShueiYang

Description

@ShueiYang

Hello! :> The behavior of useCombobox seems to have changed when upgrading from v9.0.13 to v9.2.0. And there is no clear changelog to see what happen. I would not have noticed it if one of my integration tests hadn’t caught it. After debugging, it looks like the isOpen state returned by useCombobox behaves differently when some logic is implemented inside the onStateChange prop.

However, I am not sure if there is an intentional change in how isOpen is update and it's just happen that on my implementation I rely on custom logic inside the useCombobox.stateChangeTypes.InputKeyDownEscape condition block, which now behaves differently.

What I observed

In v9.0.13:

After navigating with the keyboard in the combobox input that has an initialValue, if I press the Escape key without selecting anything: the initialValue correctly persists, and isOpen state from useCombobox is still true when log it from the onStateChange block.

In v9.2.0+:

Running the same scenario: the isOpen state from useCombobox is already false, which changes the behavior if custom logic depends on that value (write inside the onStateChange for my use case)

To Reproduce

Here I try to reproduce and add one simple test example with vitest and RTL in stackblitz (I use vitest browser mode but looks like stackblitz do not support it) the test pass in v9.013 but failed when upgrade to v9.2 or above. https://stackblitz.com/edit/vitejs-vite-12uqadji?file=src%2FCombobox.tsx

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions