Skip to content

Conversation

@jorge-cob
Copy link
Contributor

When search criteria does not match any option, a feature can be enabled that will show a button allowing to handle a given function. In the Storybook's example the function passed will set a new state with the given item.

PR-MultiSelect

  • In case enableNewFields is passed as prop, a button will render instead of the No option list item.
  • onNewField should be given a function that will be called with the search text as parameter.

Might be interesting to even allow customization of the icon and the label.

@vercel
Copy link

vercel bot commented Jul 1, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/harshzalavadiya/react-multi-select-component/FWhTqxPWu7z9Kyvh57JPhSLq3ohv
✅ Preview: https://react-multi-select-component-git-fork-jo-868023-harshzalavadiya.vercel.app

@harshzalavadiya
Copy link
Member

harshzalavadiya commented Jul 2, 2021

@jorge-cob Thank you for the PR however few points

  • instead of calling this enableNewFields we can think of it as react-select's isCreatable https://react-select.com/creatable#creatable
  • instead of rendering button we can have just simple list saying Create ${newItem}
  • Also this option should be enabled if passed via prop (not only when there are no options but no options will be hidden if isCreatable is enabled)

@jorge-cob
Copy link
Contributor Author

jorge-cob commented Jul 2, 2021

@harshzalavadiya thanks for the feedback.

Here a list of changes made to original PR:

  • enableNewFields is now named isCreatable as suggested
  • List item is rendered instead of button when no options are available.
  • When adding a new field, it gets automatically selected following https://react-select.com/creatable#creatable behaviour.

@harshzalavadiya
Copy link
Member

harshzalavadiya commented Jul 12, 2021

@jorge-cob I have made few changes and added docs but I'm not able to push the changes into this PR, can you enable allow edit from maintainers option?

also sorry for late response, I have been bit busy lately so :P

@jorge-cob
Copy link
Contributor Author

@harshzalavadiya edits by maintainers was already enabled. Maybe it's something else?

@harshzalavadiya harshzalavadiya changed the base branch from master to feat-creatable July 12, 2021 10:50
@harshzalavadiya
Copy link
Member

@jorge-cob thanks for checking out, no issues, I'll merge this with another local branch feat-creatable and then apply patch on top of that so that should work as expected

@harshzalavadiya harshzalavadiya merged commit 48344b1 into hc-oss:feat-creatable Jul 12, 2021
harshzalavadiya added a commit that referenced this pull request Jul 12, 2021
* New field feature enable in multi select when search text doesn't match any option (#416)

* New field feature enable in multi select

* Changes in response to PR comment

* refactor: ♻️ cleanup + docs

Co-authored-by: Jorge Cobreros <jorge.cobreros@protonmail.com>
@harshzalavadiya
Copy link
Member

released v4.0.3 thank you for the PR :)

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.

2 participants