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

Unclear duplication (in the form of plain text) on input #1805

Open
ahmadkeren opened this issue Jul 12, 2022 · 1 comment
Open

Unclear duplication (in the form of plain text) on input #1805

ahmadkeren opened this issue Jul 12, 2022 · 1 comment

Comments

@ahmadkeren
Copy link

Why is it that every time I finish typing in tagsinput (focus out of the text area), duplicates always appear in plain text on the form as shown in the image/video below.

Screen.Recording.2022-07-12.at.16.07.19.mov
@OvenBoy
Copy link

OvenBoy commented May 14, 2024

I know this is 2 years late - but here is my fix.

container.addEventListener('keypress', event => {
      if (event.key === 'Enter') {
        if (event.target.nodeName !== 'SPAN') {
          event.preventDefault()
          
          if (event.target.value.length === 0 || !event.target.value.trim()) return false
            
            //do insert tag
          });

        } else {
          //do delete tag
        }
        event.target.value = ' ' //reset target value (this probably isn't needed)
        $('.typeahead').typeahead('val', ' ') //"reset" typeahead val
      }
    })

In the docs, there is an API function that allows for the typeahead to be set to any value.

At least in my case, this line $('.typeahead').typeahead('val', ' ') inside the check for the enter key also works for the de-focusing issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants