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

Add helper to remove one selected option #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lhkraus
Copy link

@lhkraus lhkraus commented Mar 21, 2021

Hello guys, it would be nice to have an option that removes only one selected option, when my selector has multiple options selected, so this is my proposal.

It is my first time contributing so I hope that this is helpful.

@romgain
Copy link
Owner

romgain commented Mar 23, 2021

Hi @lhkraus , and thanks for the contribution!

I understand the use case, but we should aim to keep the API consistent.
Here are my thoughts / suggestions:

  • Rename clearOne to clear (there already is a private clear function in the project, so we'll need to rename that one as well to avoid clashes)
  • Refactor the clear function so that it accepts an optionOrOptions, like the select function
  • Refactor the clear function so that if no options are supplied, it clears the first element. Mark clearFist as deprecated and document that users should migrate to using clear without options instead.
  • When multiple options are found, I think we should clear all of them , not just the first one
  • We should throw a useful error message if one option supplied by the user cannot be found.

Let me know what you think and if you'd be interested in implementing these changes.

Thanks again!

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