Skip to content

Commit

Permalink
fix(combobox): let Downshift handle all props to fix out of sync even…
Browse files Browse the repository at this point in the history
…ts (#1725)

* fix(combobox): let Downshift handle all props to fix out of sync events

* chore(combobox): comment about spreading and events

* chore: changeset
  • Loading branch information
SiTaggart committed Aug 4, 2021
1 parent b02b0d6 commit b0e8ab8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/tall-phones-rescue.md
@@ -0,0 +1,6 @@
---
'@twilio-paste/combobox': patch
'@twilio-paste/core': patch
---

Allow Downshift to handle input events past by the component consumer. This allows for event data and internal state of the combobox to stay in sync correctly
4 changes: 2 additions & 2 deletions packages/paste-core/components/combobox/src/Combobox.tsx
Expand Up @@ -151,11 +151,11 @@ const Combobox = React.forwardRef<HTMLInputElement, ComboboxProps>(
<ComboboxInputWrapper {...getComboboxProps({role: 'combobox'})}>
<ComboboxInputSelect
{...getToggleButtonProps({tabIndex: 0})}
{...getInputProps({disabled, required, ref})}
// we spread props into `getInputProps` so that Downshift handles events correctly
{...getInputProps({disabled, required, ref, ...props})}
{...(!autocomplete ? {onChange: (event: React.ChangeEvent) => event.preventDefault()} : undefined)}
autocomplete={autocomplete}
aria-describedby={helpTextId}
{...props}
type="text"
/>
{!autocomplete && (
Expand Down
12 changes: 12 additions & 0 deletions packages/paste-core/components/combobox/src/types.ts
Expand Up @@ -54,6 +54,18 @@ export interface ComboboxProps extends Omit<InputProps, 'id' | 'type' | 'value'>
groupItemsBy?: string;
variant?: InputVariants;
state?: Partial<UseComboboxPrimitiveReturnValue<any>>;
/**
* Use `onInputValueChange` instead.
* @type {never}
* @memberof ComboboxProps
*/
onChange?: never;
/**
* Use `onInputValueChange` instead.
* @type {never}
* @memberof ComboboxProps
*/
onInput?: never;
}

export interface ComboboxItemsProps
Expand Down

0 comments on commit b0e8ab8

Please sign in to comment.