-
Notifications
You must be signed in to change notification settings - Fork 436
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
Tags get broken when clicking on label #1260
Comments
This is also an issue if the input is located inside the label. The focus is moved to the (usually) hidden input immediately upon focusing the Tagify component. This causes the dropdown to close immediately. |
@AaronAsAChimp - the JSBIN you posted seems to lack any modifications which showcases an issue |
@yairEO I'm not sure what happened there. This bin should show the issue (I doubled checked it 😁). https://jsbin.com/nanapotihe/edit?html,js,output Edit: Here is the code that causes the issue in case anything weird happens to the jsbin. <label>
<input placeholder="type tags">
</label> var input = document.querySelector('input')
var tagify = new Tagify(input) |
Tagify cannot work with inputs which reside inside <label for=''> |
Thank you, I found something that works. Adding the following to my above example makes it work as expected. Could this or something similar be integrated into Tagify? If not that's ok, but I like the usability that the label provides. function redirectFocus(e) {
e.preventDefault()
const tagifyInput = e.target.querySelector('.tagify__input');
if (tagifyInput) {
tagifyInput.focus();
}
}
input.labels.forEach((label) => {
label.addEventListener('click', redirectFocus);
}) |
please use event delegation and do not bind an event on each individual element. ask you can also just do this in your e.target.querySelector('.tagify__input')?.focus() I don't want Tagify to directly mess with HTML elements in the page and prefer to leave that for developers to solve. |
Prerequisites
💥 Demo Page
https://jsbin.com/hovosavawe/edit?html,js,output
Explanation
Start typing in input and hold down some key and the same time click on input label(still holding down the key).
tags not get broken
Tags get broken, result for example when holding down key "d"
{"value":"{"value":"{\"value\":\"ddddddddddddddd\"}]dd"}]dddddddddddd"}]dddddddd
no errors
The text was updated successfully, but these errors were encountered: