Bug Description
When editing text in the middle of a combobox input field, the cursor automatically jumps to the end of the text instead of staying at the current position. This makes it difficult to edit text that's not at the end of the input.
Root Cause
The issue was caused by asynchronous state updates using setTimeout in the combobox primitive component:
- setTimeout(() => onInputValueChange(search, "inputChange"));
inComboboxInput.onValueChange`
setTimeout(() => onOpenChange(false)); in ComboboxItem.onSelect
These setTimeout calls delayed state updates to the next tick, causing React to re-render the component after the cursor position was already lost, resulting in the cursor jumping to the end.
For i now i just removed the setTimeout. I could just create a pr for the same but i have no idea why was setTimeout there in the first place.