Skip to content

Commit

Permalink
fix(combobox): preserve combobox cursor position upon change
Browse files Browse the repository at this point in the history
  • Loading branch information
Powerplex committed May 3, 2024
1 parent 35c2ce5 commit 4ba34da
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/components/combobox/src/ComboboxInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ export const Input = forwardRef(
multiselectInputProps.onKeyDown?.(event)
ctx.setLastInteractionType('keyboard')
},
/**
*
* Important:
* - without this, the input cursor is moved to the end after every change.
* @see https://github.com/downshift-js/downshift/issues/1108#issuecomment-674180157
*/
onChange: (e: React.ChangeEvent<HTMLInputElement>) => {
ctx.setInputValue(e.target.value)
},
ref: inputRef,
})

Expand Down

0 comments on commit 4ba34da

Please sign in to comment.