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

Creatable includes promptText in the onChange payload #1464

Closed
roderickhsiao opened this issue Jan 5, 2017 · 10 comments
Closed

Creatable includes promptText in the onChange payload #1464

roderickhsiao opened this issue Jan 5, 2017 · 10 comments

Comments

@roderickhsiao
Copy link

roderickhsiao commented Jan 5, 2017

We are using v1.0.0-rc2

while using Creatable, the onChange payload includes the promptText in the payload.value attribute .

import React from 'react';
import { Creatable } from 'react-select';

class Demo extends React.Component {
    render() {
        return (
            <Creatable onChange={(payload) => console.log(payload.value)} />
        );
    }
}

value turns out to be the full Create option "${label}" instead of just label

We are passing promptTextCreator={(name) => name} to by pass the issue

@jsnmoon
Copy link

jsnmoon commented Jan 5, 2017

I'm also running into this bug; the above workaround works, but it's less than satisfactory as custom prompt text is no longer possible.

@sir4ur0n
Copy link

Hello,

Can you explain why you closed this issue? The problem does happen in 1.0.0-rc2 version.
IMHO it should be reopened.

@roderickhsiao
Copy link
Author

I close this as I found that its because our implementation that passing incorrect shouldKeyDownEventCreateNewOption, passing correct function like shouldKeyDownEventCreateNewOption={({ keyCode }) => keyCode === 13} then I didn't see the bug

@roderickhsiao
Copy link
Author

Reopen as other seeing the same issues

@roderickhsiao roderickhsiao reopened this Jan 12, 2017
@sir4ur0n
Copy link

Seems to be fixed in 1.0.0-rc3.

@purplesquirrels
Copy link

I just ran into this issue and I am using 1.0.0-rc3, however the solution from @roderickhsiao seems to fix the problem. I was not using shouldKeyDownEventCreateNewOption previously.

@ayozebarrera
Copy link

I'm in 1.0.0-rc.2 and ran into the issue and like @roderickhsiao and @purplesquirrels said, using shouldKeyDownEventCreateNewOption function should fix it.

Thanks guys

@banuni
Copy link

banuni commented Aug 6, 2017

note that you'll probably want to respond to keyCode === 9 to handle Tab keys

@aleksey-shmatov
Copy link

aleksey-shmatov commented Apr 12, 2018

This is still happening for me in 1.2.1 when I use react-select inside redux form. I tried to provide shouldKeyDownEventCreateNewOption function but it did not help. After some debugging I found out that this condition: if (option === this._createPlaceholderOption) in onOptionSelect of Creatable is never true for me.

@bladey
Copy link
Contributor

bladey commented May 27, 2020

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 aren't using the latest version of react-select please consider upgrading to see if it resolves any issues you're having.

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.

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

8 participants