Skip to content

Commit

Permalink
Merge pull request #2111 from adevinta/preserve-combobox-cursor-position
Browse files Browse the repository at this point in the history
fix(combobox): preserve combobox cursor position upon change
  • Loading branch information
Powerplex authored May 3, 2024
2 parents 35c2ce5 + 4ba34da commit cf1b3cf
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 cf1b3cf

Please sign in to comment.