DominoKit / domino-ui

Domino-ui
Apache License 2.0
217 stars 44 forks source link

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

Closed howudodat closed 3 months ago

howudodat commented 5 months ago

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 commented 3 months ago

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 commented 3 months ago

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

vegegoku commented 3 months ago

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.