From 4ba34da2a5a8dbec9d48f735b624783d4df5f2fe Mon Sep 17 00:00:00 2001 From: Powerplex Date: Fri, 3 May 2024 16:35:43 +0200 Subject: [PATCH] fix(combobox): preserve combobox cursor position upon change --- packages/components/combobox/src/ComboboxInput.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/components/combobox/src/ComboboxInput.tsx b/packages/components/combobox/src/ComboboxInput.tsx index 644c6342a..4adbaf065 100644 --- a/packages/components/combobox/src/ComboboxInput.tsx +++ b/packages/components/combobox/src/ComboboxInput.tsx @@ -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) => { + ctx.setInputValue(e.target.value) + }, ref: inputRef, })