segmentio / evergreen

🌲 Evergreen React UI Framework by Segment
https://evergreen.segment.com
MIT License
12.38k stars 830 forks source link

Autocomplete: allowOtherValues does not work #1562

Closed harish-prakash closed 1 year ago

harish-prakash commented 1 year ago

Steps to reproduce Use the <Autocomplete/> component with allowOtherValues prop.

const Page = () => {
  const [value, setValue] = useState('')
  return (
    <div>
      <Autocomplete
        allowOtherValues
        id="autocomplete-test"
        onChange={setValue}
        items={[
          'red',
          'green',
          'yellow',
          'this does not render on the textbox but sets the state correctly'
        ]}
      >
        {({ getInputProps, getRef, openMenu, inputValue }) => {
          return (
            <TextInput
              ref={getRef}
              {...getInputProps({ onFocus: openMenu })}
              value={inputValue}
            />
          )
        }}
      </Autocomplete>
      <Button onClick={() => console.debug('value... ', value)}>
        Log Value
      </Button>
    </div>
  )
}
brandongregoryscott commented 1 year ago

Hi @harish-prakash, what version are you using? I believe this was fixed with #1496 / https://github.com/segmentio/evergreen/releases/tag/v6.10.4. Here's a CodeSandbox with your example code: https://codesandbox.io/s/issue-1562-38zjfj?file=/src/App.tsx

harish-prakash commented 1 year ago

I see that this was fixed in 6.10.4, I am using 6.10.3 🤦‍♂️. Closing this issue 🙌