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

simpleValue for User-Created Tags Not Working Properly

Open amshim opened this issue 9 years ago • 8 comments

I am trying to use simpleValue={true} for <Creatable /> tags. The pre-written labels work correctly, but when the user types in a custom tag, it does not work. However, they do get written properly to the state, they just don't show up when rendered.

<Select.Creatable multi={true} options={[ { label: 'A', value: 'A' }, { label: 'B', value: 'B' }, { label: 'C', value: 'C' }, ]} onChange={this.handleTestTagInput} value={this.props.printTest.testTags} simpleValue={true} />

For the above example. Selecting A, B or C works and displays correctly. Any custom tags that are entered in do not physically show up, but they are registered into the string.

Is this a known issue? Any work around this?

edit: moreover, when I enter in a new custom tag and press my 'enter' key, it deletes all of the previous custom tags and inserts the new one into the string. However, clicking on 'click option' adds it just fine.

amshim avatar Jan 24 '17 11:01 amshim

I have the same issue. When the user enters a new tag, the state updates correctly but the ui does not add the new tag the user just created, it says "Create option XXXX".

This is my Creatable tag:

let options = [
      { value: 'Pedro', label: 'Pedro' },
      { value: 'Martina', label: 'Martina' }
    ];
<Creatable
                  name="clients"
                  value={'Pedro'}
                  options={options}
                  onChange={this.handleOnChangeSelect}
                />

I attach screenshots showing the issue. screen shot 2017-06-09 at 12 01 06 pm screen shot 2017-06-09 at 12 00 57 pm

jmoller avatar Jun 09 '17 14:06 jmoller

I think the mistake lies on putting the options object in the render method or in your case directly in the Creatable tag.

I put the options object in the state and set the Creatable options to this.state.options and now it works just fine. Hope this helps someone!

jmoller avatar Jun 09 '17 15:06 jmoller

I have the same issue with the latest version (1.0.0-rc.5 at the moment). Creatable works fine unless simpleValue={true} is passed. @jmoller's solution didn't work for me (may be I didn't understand it properly). Any ideas, @JedWatson? At the moment I have to transform the data before sending to API manually (to have arrays of strings rather than objects).

yantakus avatar Sep 12 '17 15:09 yantakus

Hello -

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

We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our limited efforts to maintain the latest version.

If you feel this issue / pull request 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 27 '20 06:05 bladey

why are you closing it? simplevalue does not work for creatable.

ghost avatar Jun 03 '20 17:06 ghost

Thanks for the feedback @canercak, much appreciated.

bladey avatar Jun 03 '20 23:06 bladey

I've started a fork of react-select. Feel free to resubmit this issue on the fork and/or submit a PR to resolve this issue on the fork and we can get it merged and released.

Methuselah96 avatar Nov 14 '20 16:11 Methuselah96

why are you closing it? simplevalue does not work for creatable.

simpleValue was depreciated after version 1 (current version is 3.1.1) and there has been no followup on supporting this in over 3 years.

In the interest of focusing on functionality and stability for current and future versions, we will be closing this. This issue can always be reopened should anyone have enough interest in creating a PR to address this.

ebonow avatar Dec 02 '20 04:12 ebonow