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

Fix creatable not supporting Int values and value accessors #2955 #2953 #2956

Closed

Conversation

th3fallen
Copy link

Resolves #2955 and #2953

@akre54
Copy link
Contributor

akre54 commented Aug 22, 2018

Just saw this PR. Unfortunately this doesn't fix #2953, as that will still use the default option.label and option.value instead of the custom fields. I created #2964 for that use case.

I'm wondering for this bug if we can just check for the presence of toLowerCase instead of casting to a string? Since '2345' doesn't have a lowercase representation, and will allow for other things like passing objects as values.

The alternative is the library can expose compareOption as an overridable option instead of needing to replace the entire isValidNewOption logic.

@th3fallen
Copy link
Author

i thought about checking their types but that seemed like a lot of overhead and i wasnt super familiar with the codebase so i didnt want to get too far down a rabbit hole

@akre54
Copy link
Contributor

akre54 commented Aug 22, 2018

I would do

(option.value.toLowerCase ? option.value.toLowerCase() : option.value === candidate) ||
(option.label.toLowerCase ? option.label.toLowerCase() : option.label === candidate)

This only solves this bug. To solve both #2955 and #2953 you should save value and label to temp variables:

const value = getOptionValue(option);
const label = getOptionLabel(option);
(value.toLowerCase ? value.toLowerCase() : value) === candidate ||
(label.toLowerCase ? label.toLowerCase() : label) === candidate

@webzfactory
Copy link

Any ideas when this will be merged? It looks like a standard use case.

@Alphonse-Indpro
Copy link

Any ideas when this will be merged? It looks like a standard use case.

Fixed in v2.3.0 / 2019-01-18 https://github.com/JedWatson/react-select/releases/tag/v2.3.0

@bladey
Copy link
Contributor

bladey commented Jun 3, 2020

Hi @th3fallen,

As pointed out by @Alphonse-Indpro, it appears this PR is no longer required.

However - if you feel this pull request is still relevant for the latest version, let us know and we'll determine if it should be reopened.

@bladey bladey closed this Jun 3, 2020
@akre54
Copy link
Contributor

akre54 commented Jun 3, 2020

Thank you for the more thoughtful response here. That pull request doesn't fix the main issue, though, which is that the library is looking for label and value props on each option and ignoring the getOptionLabel/getOptionValue functions which are supposed to help in this case.

@bladey
Copy link
Contributor

bladey commented Jun 3, 2020

Thanks for letting me know @akre54.

@bladey bladey reopened this Jun 3, 2020
@bladey bladey added pr/bug-fix PRs that are specifically addressing a bug pr/needs-review PRs that need to be reviewed to determine outcome and removed deprecated labels Jun 4, 2020
@ebonow
Copy link
Collaborator

ebonow commented Mar 7, 2021

Greetings @th3fallen ,

Sorry for the extremely late reply to your PR submission. There is quite a backlog of user submitted PR's and the community deserves better than waiting months or years for a collaborator to reply to the work they've done.

I wanted to let you know that the issues that this PR addresses has been resolved:
https://github.com/JedWatson/react-select/pull/3316/files
https://github.com/JedWatson/react-select/pull/4444/files

As such, I will be closing this, though I feel frustrated for you that this took so long to get resolved and wanted to add that I truly appreciate the time you put into coding a solution. Thank you for being a part of the community and contributing to react-select.

@ebonow ebonow closed this Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/bug-fix PRs that are specifically addressing a bug pr/needs-review PRs that need to be reviewed to determine outcome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[V2] Creatable crashes with values without toLowerCase in prototype
6 participants