Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inputValue.trim is not a function when using object array for items in autocomplete with "allowOtherValues" #1652

Open
nikhilism15 opened this issue Jun 26, 2023 · 0 comments

Comments

@nikhilism15
Copy link

nikhilism15 commented Jun 26, 2023

I have an autocomplete implementation where I am using an object array for the items, and I also want to have the property allowOtherValues to be true - but I get the error "inputValue.trim is not a function" when I try to select any item from the options.

Here's my code (sorry for the formatting, don't know why this is happening this way):

export const Simple = ({ name }: SimpleProps) => { return ( <> <Autocomplete items={[ { name: 'TABLE 1', tableId: 'table1' }, { name: 'TABLE 2', tableId: 'table 2' }, ]} itemToString={(item) => (item ? item.name : '')} onChange={(item) => console.log(item)} allowOtherValues={true} initialInputValue="TABLE 1" > {(props) => { const { getInputProps, getRef, inputValue, openMenu } = props; return ( <TextInput placeholder="Open on focus" value={inputValue} ref={getRef} {...getInputProps({ onFocus: () => { openMenu(); }, })} /> ); }} </Autocomplete> </> ); };

This seems to be a simple issue where the inputValue is assumed to be a string but it's actually an object. However, one would assume that if the Autocomplete has the itemToString property populated, then the trim function wouldn't apply on the object itself but the itemToString transformation of said object. Can you please sort this out?

DevJoaoLopes added a commit to DevJoaoLopes/evergreen that referenced this issue Jul 29, 2023
DevJoaoLopes added a commit to DevJoaoLopes/evergreen that referenced this issue Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant