Skip to content

missing generic implementation in select file #72

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

Closed
wants to merge 1 commit into from
Closed

missing generic implementation in select file #72

wants to merge 1 commit into from

Conversation

Taha-Firoz
Copy link

I was having issues when I had a custom optionIdentifier paired with isMulti & isCreatable. I am using it as a tag input solution in my project and whenever I added a new input it wouldn't show the default create message, it would show undefined. I tracked down the issue to be in the Select file, it wasn't appending the generic optionIdentifier in the _filteredItems array it was appending specifically label. I changed label: our for optionIdentifier and everything started to work.

The library is great since the combination fo svelte and bulma doesn't give us many choices in input fields and yours is very ergonomic.

@subpx subpx self-requested a review August 18, 2019 20:19
@subpx
Copy link
Contributor

subpx commented Aug 18, 2019

This solution doesn't seem quite right. I think we need some more tests for isCreatable and make sure we are handling all scenarios. There is a function that is used for creating new items, we could probably use that to create the creator item as well. @rob-balfre what are your thoughts?

@rob-balfre
Copy link
Owner

@Taha-Firoz thanks for the PR! You're right it shouldn't show undefined but your change causes a test to fail. @subpx's suggestion is prob a better approach that doesn't cause breaking changes.

@rob-balfre
Copy link
Owner

rob-balfre commented Aug 18, 2019

@subpx
Copy link
Contributor

subpx commented Aug 18, 2019

@rob-balfre With that solution you could never have multiple items created by the same filter text.

@Taha-Firoz
Copy link
Author

@rob-balfre I really don't understand that solution since the createItem function I'm using doesn't have any field called label . I did notice that optionIdentifier is used to represent the value field instead of the label one, but in my case the value and label fields are the same.

@subpx I didn't know svelte-select even allowed multiple items to be added by the same filter text. Could you explain on how I can make this fix without failing the tests?

@rob-balfre
Copy link
Owner

@Taha-Firoz can you make a REPL of how you're trying to use svelte-select please? You can use this one as a base... https://svelte.dev/repl/f3bc0fd6b6f74ea499e5ecb26911bf28?version=3.6.8

@Taha-Firoz
Copy link
Author

@rob-balfre https://svelte.dev/repl/ba5d877d743545f28ea9b1b1e4e23dea?version=3.6.8
Okay so this is almost exactly our use case, try adding a new tag and it doesn't show the Create foo it just shows undefined

@rob-balfre
Copy link
Owner

@Taha-Firoz updated https://github.com/rob-balfre/svelte-select/tree/feature/isMulti_isCreatable_optionIdentifier

@Taha-Firoz
Copy link
Author

@rob-balfre I was thinking of exactly that, adding a label identifier but dismissed the idea and just tried to make do with whatever existed already. Should I close the PR now?

@subpx
Copy link
Contributor

subpx commented Aug 20, 2019

@rob-balfre This is not going to work when using getOptionLabel

@rob-balfre
Copy link
Owner

@subpx I updated getOptionLabel too (see the changes/tests). Should be backwards compatible too. Unless I'm missing something?

@subpx
Copy link
Contributor

subpx commented Aug 20, 2019

@rob-balfre Ive still got a breaking test. Give me bit and I will do a push.
OK there are a couple of example failing tests

@rob-balfre
Copy link
Owner

@subpx thanks, yeah thats pretty crappy. hmmm short of refactoring isCreatable not sure of a work around.

@subpx
Copy link
Contributor

subpx commented Aug 20, 2019

@rob-balfre should be pretty straight forward without getCreateLabel. I say we remove that.
More flexibility having that handled within the createItem method. I will push something later today

@rob-balfre
Copy link
Owner

@subpx worked his magic.

@Taha-Firoz here ya go https://svelte.dev/repl/db8ab7241f5946ee922100bfec33cb1c?version=3.9.0

Gonna close this PR now.

@rob-balfre rob-balfre closed this Aug 21, 2019
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

Successfully merging this pull request may close these issues.

3 participants