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

[feat]: options to control when auto-complete popover is displayed #90

Open
2 tasks done
Mirthis opened this issue Aug 29, 2024 · 2 comments
Open
2 tasks done

[feat]: options to control when auto-complete popover is displayed #90

Mirthis opened this issue Aug 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Mirthis
Copy link

Mirthis commented Aug 29, 2024

Feature description

It would be useful to have more control on when the popover shows up.
For instance I would prefer not to have suggestions when the input is empty as having a long list of suggestions to shows up immediately is not ideal.
I would also prefer not to show anything when there's no matching suggestion rather then having the no result popover.

Additional Context

Additional details here...

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues and PRs
@JaleelB JaleelB added the enhancement New feature or request label Aug 29, 2024
@patrickabernathy
Copy link

patrickabernathy commented Nov 7, 2024

Editing my previous post:

I've been working on something very similar to this. I think there is a bug with autocomplete and setting inlineTags to false but that's what I'm using currently. This should be easily modifiable for inline. I'm using the onInputChange event to track the input field and then use styling to hide and show only once the user starts typing. I also keep track of the current autocomplete array and check it myself so that I can hide the window in the case of no results available. Hope this helps.

const [currentTagValue, setCurrentTagValue] = useState<string>('');
const [autoCompleteFound, setAutoCompleteFound] = useState<boolean>(true);

const handleAutocompleteFilter = async (tagFilter: string) => {
  setCurrentTagValue(tagFilter);
  
  var found = false;
  for(var i = 0; i < autoCompleteTags.length; i++) {
    if (autoCompleteTags[i].text.toLowerCase().includes(tagFilter)) {
      setAutoCompleteFound(true);
      found = true;
      break;
    }
  }
  if (!found){
    setAutoCompleteFound(false);
  }
}

<TagInput
  onInputChange={(tag) => {
    handleAutocompleteFilter(tag);
  }}
  styleClasses = {
    {
      autoComplete:{
        popoverContent: `${currentTagValue == '' ? 'hidden' : 'max-h-[260px] overflow-y-auto'} bg-white`,
        popoverTrigger:  `${!autoCompleteFound ? 'hidden' : 'text-white'}`,
        commandList: `${!autoCompleteFound ? 'hidden' : ''}`,
        commandGroup:  `${!autoCompleteFound ? 'hidden' : ''}`,
        commandItem:  `${!autoCompleteFound ? 'hidden' : ''}`,
      }
    }
  }

/>

@Mirthis
Copy link
Author

Mirthis commented Nov 7, 2024

Thanks @patrickabernathy for the suggestion.
I'll try to implement something similar and report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants