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

SuggestBox clearValue(...) does not clear value if it isnt predefined choice #940

Closed
howudodat opened this issue May 30, 2024 · 3 comments
Closed
Assignees
Labels
enhancement New feature or request version 2.x.x Version 2.x.x issues
Milestone

Comments

@howudodat
Copy link

There's two problems with this code:

  @Override
  protected SuggestBox<V, E, O> clearValue(boolean silent) {
    if (nonNull(selectedOption)) {
      V oldValue = getValue();

if I have typed, but not selected an option, there wont be a selected option so delete wont clear anything

additionally, even though I have selected an item (and get the notification for it), selectedOption is still null

@vegegoku vegegoku self-assigned this Jun 25, 2024
@vegegoku vegegoku added bug Something isn't working version 2.x.x Version 2.x.x issues labels Jun 25, 2024
@vegegoku vegegoku added this to the 2.0.2 milestone Jun 25, 2024
@vegegoku vegegoku changed the title V2 SuggestBox doesn't clear SuggestBox clearValue(...) does not clear value if it isnt predefined choice Jul 15, 2024
@vegegoku
Copy link
Member

I guess the reason behind this issue is that you didnt add the missing entry/value provider for the suggestions store, like this

 LocalSuggestionsStore<String, SpanElement, SuggestOption<String>> localStore = LocalSuggestionsStore.<String, SpanElement, SuggestOption<String>>create()
                .addSuggestion(SuggestOption.create("Ahmad bawaneh"))
                .addSuggestion(SuggestOption.create("Ahmad Ali"))
                .addSuggestion(SuggestOption.create("Ali omar"))
                .addSuggestion(SuggestOption.create("Ali hasan"))
                .addSuggestion(SuggestOption.create("Schroeder Coleman"))
                .addSuggestion(SuggestOption.create("Renee Mcintyre"))
                .addSuggestion(SuggestOption.create("Casey Garza"))
                .setMissingEntryProvider(inputValue -> Optional.of(SuggestOption.create(inputValue)))
                .setMissingValueProvider(missingValue -> Optional.of(SuggestOption.create(missingValue)));

@howudodat
Copy link
Author

I dont want it to create new items, I am only using this as a filterable select

@vegegoku
Copy link
Member

I dont want it to create new items, I am only using this as a filterable select

It is not about creating a new Item, but since a suggest box can have any type of value, not only strings it is internally deals with suggest options, and it assumes that in case a string value is entered then it need to be converted to a type supported by the suggest box value.

Still I guess clearing the text value of the input element either way wont be an issue.

@vegegoku vegegoku added enhancement New feature or request and removed bug Something isn't working labels Jul 26, 2024
vegegoku added a commit that referenced this issue Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request version 2.x.x Version 2.x.x issues
Projects
Status: Done
Development

No branches or pull requests

2 participants