headlessui icon indicating copy to clipboard operation
headlessui copied to clipboard

`immediate` prop does not work well in React 18.2

Open krzykro2 opened this issue 9 months ago • 0 comments

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.

krzykro2 avatar Feb 25 '25 16:02 krzykro2