-
Notifications
You must be signed in to change notification settings - Fork 435
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
Limit the characters or remove the character if max exceeds. #1306
Comments
For now you can use |
If this is set to false the user cannot edit or update the text. There should be a way that user can remove the text and type until the limit reaches. |
isn't there a way that we can simply remove the characters those exceeded the max length ? |
you can tap into the const MAX_CHARS = 100;
const tagify = new Tagify(...)
tagify.on('input', e => {
console.log(e.detail)
// count the number of characters
// you can also call this with either `true` or an error string to mark the field as invalid:
tagify.toggleScopeValidation(true || 'maximum characters reached')
}) |
So I managed to disable the button by getting the total. But I am facing weird behavior in non react input, it clears the input if state is called inside the INPUT callback, but works fine in the react version. Issues facing with react and non react version:
Expected: Sharing the sandbox link below |
Also I just noticed tha in react version if you add the tag by clicking on it from the dropdown it moves the cursor to the start of sentence, if you use keyboard to add it then works fine. |
you should open a new issue and please be clearer. You mean |
Prerequisites
Demo Page - clone one of the below:
https://jsbin.com/jekuqap/edit?html,js,output
React issue template:
https://codesandbox.io/s/tagify-react-issue-template-4ub1r?file=/src/index.js
I am using tagify in one of my react projects.
I was trying to limit the max characters that a user can input in mix mode. A total of tags and text.
Somehow managed to removed the last tag using the onChange callback, but this is also not accurate as it will remove all the tags if user keeps on typing text.
Can we somehow set the useInput to false at this position I tried the below, but nothing happened.
Have been trying in many different ways but no success. In simple words the input text should be sliced after max char increase, and if there's a tag at the end it should be removed not sliced.
The text was updated successfully, but these errors were encountered: