Skip to content

immediate prop does not work well in React 18.2 #3659

Open
@krzykro2

Description

@krzykro2

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

2.2.0

What browser are you using?

Chrome

Reproduction URL

https://codesandbox.io/p/sandbox/rvmjcv

Describe your issue

Changing the immediate prop on the Combobox does not immediately reflect behavior change. If the component is initiated with immediate={false}, and then its prop value changes to true then it will still not show the options on focus, until something is typed in. Afterwards, the component behaves correctly (e.g. if the input is cleared and the focus is released, next time the component receives focus it will correctly show the options).

Only reproducible in React 18.2. Updating the immediate prop seems to work correctly in React 19.

In the attached example the component should behave with the behavior of immediate={true} (as it's set to true in the first useEffect cycle), but instead it behaves as if immediate was set to false, until something is typed in.

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