What is the expected behavior?
It should verify if document.activeElement is an element related to tagify before calling blur()
What is happening instead?
The blur() method is called on document.activeElement regardless of whether the active element is part of Tagify. This leads to a scenario where any focused element will lose focus, disrupting user interactions outside of the Tagify context.
Prerequisites
💥 Demo Page
https://jsbin.com/yododahodi/edit?html,js,output
Explanation
What is the expected behavior? It should verify if
document.activeElement
is an element related to tagify before callingblur()
What is happening instead? The
blur()
method is called ondocument.activeElement
regardless of whether the active element is part of Tagify. This leads to a scenario where any focused element will lose focus, disrupting user interactions outside of the Tagify context.https://github.com/yairEO/tagify/blob/3ecfbc2ed1de444bdcdbb10d8b62a61ae2fdc8fa/src/tagify.js#L1011 I'm unsure what this line is meant to do. I guess it's here to exit edit-mode on tags, as the tagify input should loose focus naturally when it has the readonly/disabled attribute.