react-select icon indicating copy to clipboard operation
react-select copied to clipboard

After one selection is made, all subsequent options appear selected.

Open claytongroth opened this issue 7 years ago • 4 comments

I am having an issue where the first selection I make yields normal options to select from that render properly: stepone

Then, when I blur and type something again, I get: steptwo

Below is the component:

<AsyncSelect
    isClearable
    isDisabled={this.props.disabled}
    inputValue={this.state.query}
    autoBlur
    blurInputOnSelect
    placeholder={this.state.placeholder}
    // Fire the api here and get results async
    loadOptions={this.loadOptions}
    //just updates the state
    onInputChange={this.handleInputChange} 
    onChange={this.handleChange}
    components={
        {
            DropdownIndicator: () => null,
            IndicatorSeparator: () => null,
            NoOptionsMessage: () => <div>Start typing a destination</div>

        }
    }
/>

Expected behavior: The component is styled in the same way before and after I select+blur it.

I am hoping there is some prop that I can tweak to prevent this behavior?

claytongroth avatar Oct 03 '19 02:10 claytongroth

I'm having a similar issue. In my case, loadOptions doesn't return an array of plain strings but an array of objects (ex: [{country: "xyz", city: "abc"}, ....])

I managed to fix this by providing an isOptionSelected prop.

https://github.com/JedWatson/react-select/blob/master/packages/react-select/src/Select.js#L1286

Hope it helps!

arnaudj avatar Oct 30 '19 14:10 arnaudj

@claytongroth What is the value of the value attribute of your options? All options being selected would mean they all share the same value.

Rall3n avatar Dec 10 '19 12:12 Rall3n

Hello -

In an effort to sustain the react-select project going forward, we're closing old issues.

We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our efforts towards the current major version.

If you aren't using the latest version of react-select please consider upgrading to see if it resolves any issues you're having.

However, if you feel this issue is still relevant and you'd like us to review it - please leave a comment and we'll do our best to get back to you!

bladey avatar May 28 '20 04:05 bladey

I have the same issue, solved it using the below approach. Select "options" should contain the key "value". Example: const countries =[ { code: 'AD', label: 'Andorra', phone: '376' ,value:'' }, { code: 'AE', label: 'United Arab Emirates', phone: '971', value:'' } { code: 'IN', label: 'India', phone: '91', value:'' } ]

If you remove the "value" from above list item then we are experiencing this problem. Hope this helps..!!

suryavenkat506 avatar Nov 23 '22 08:11 suryavenkat506