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

Double-click tag fires both "edit" & "click" custom events #247

Closed
shakeeb-mts opened this issue May 29, 2019 · 5 comments
Closed

Double-click tag fires both "edit" & "click" custom events #247

shakeeb-mts opened this issue May 29, 2019 · 5 comments

Comments

@shakeeb-mts
Copy link

When we double click a tag to edit it should not trigger the click. Currently it is generating 2 click event.

As I am running some test which is CPU intensive per tag on click and show the result of them but when I go for editing the callback is still running.

Any quick solution would be highly appreciated.

Rest the library is great KUDOS for that.

@yairEO
Copy link
Owner

yairEO commented May 29, 2019

For now I think this solution should work for you (haven't tested it)

function applyTagify(){
    const tagify = new Tagify(...);
    let clickTimeout; // declare a timeout variable at the same scope where tagify is declared

    tagify.on('click', onClick)
          .on('edit', onEdit)

    function onClick(e){
        if( e.detail.classList.contains("tagify--editable") ){
            clickTimeout && clearTimeout(clickTimeout);
            return;
        }

        clickTimeout = clickTimeout || setTimeout(()=>{
            ...CPU-intensive code here...
            clickTimeout = null; // reset
        }, 400) 
    }

    function onEdit(){
        ...
    }
}

@yairEO yairEO changed the title Wrong event triggering Double-click tag fires both "edit" & "click" custom events Jun 6, 2019
@shakeeb-mts
Copy link
Author

shakeeb-mts commented Jun 18, 2019

Hi @yairEO any luck doing it. The above code is not working.

@yairEO
Copy link
Owner

yairEO commented Jun 18, 2019

I didn't test the above code, it's probably a minor thing, so I will test it soon and let you know. There is no internal "fix" to this, and one must work out a specific fix outside of Tagify's scope (as shown above)

@shakeeb-mts
Copy link
Author

Hi we can add a double click event in the library just like click event.

@yairEO
Copy link
Owner

yairEO commented Oct 14, 2019

@shakeeb-mts - why do you need to know about a double-click event being fired?
it's the same as editTag event, if you allow tag-editing

@yairEO yairEO closed this as completed Nov 21, 2019
@yairEO yairEO self-assigned this Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants