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

Question: combobox item callback #2527

Open
ptmdmusique opened this issue Jul 13, 2021 · 2 comments
Open

Question: combobox item callback #2527

ptmdmusique opened this issue Jul 13, 2021 · 2 comments
Labels
0 - new New issues that need assignment.
Milestone

Comments

@ptmdmusique
Copy link
Contributor

ptmdmusique commented Jul 13, 2021

Question

Is there anyway we can expose something like a isValid callback for calcite-combobox-item or calcite-combobox so we can validate the item the user adds before actually add it to the combobox

We're having a tag list feature for items and one of the issue came up is that tags that have trailing/leading spaces are considered as separated tags. So, I think having a callback to validate the tag before adding it to the combobox would be the solution in the long run

cc @paulcpederson

@ptmdmusique ptmdmusique added 0 - new New issues that need assignment. question labels Jul 13, 2021
@driskull
Copy link
Member

driskull commented Jul 29, 2021

We can probably add a property to do this:

  /**
   * When provided, this method will be called before a custom value is added. 
   * Depends on 'allowCustomValues' being true.
   */
  @Prop() beforeAddCustomValue?: () => Promise<void>;

What do you think @paulcpederson ?

@paulcpederson
Copy link
Member

This is a nice approach!

I would change the promise signature slightly so that the resolved value is what we use for the custom value. That way a dev could transform things if need be (ie escape certain chars, dedupe things, etc). If resolved with a falsey value this could stop the addition entirely?

@Prop() beforeAddCustomValue?: (customValue: string) => Promise<string|false>;

or something like that.

@driskull driskull added the needs triage Planning workflow - pending design/dev review. label Aug 11, 2021
@jcfranco jcfranco added this to the Freezer milestone Aug 11, 2021
@jcfranco jcfranco removed the needs triage Planning workflow - pending design/dev review. label Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - new New issues that need assignment.
Projects
None yet
Development

No branches or pull requests

6 participants