Fixed #2371 - StyleClass may fail to enter the element

pull/2372/head
Tuğçe Küçükoğlu 2022-03-30 15:07:10 +03:00
parent 8fcf738b85
commit b3a21e0182
1 changed files with 11 additions and 2 deletions

View File

@ -137,10 +137,11 @@ function resolveTarget(el, binding) {
function bindDocumentListener(target, el, binding) {
if (!target.$p_styleclass_documentlistener) {
target.$p_styleclass_documentlistener = (event) => {
if (getComputedStyle(target).getPropertyValue('position') === 'static') {
if (isVisible(target) || getComputedStyle(target).getPropertyValue('position') === 'static') {
unbindDocumentListener(target);
}
else if (!el.isSameNode(event.target) && !el.contains(event.target) && !target.contains(event.target)) {
else if (isOutsideClick(event, target, el)) {
leave(target, binding);
}
}
@ -156,6 +157,14 @@ function unbindDocumentListener(target) {
}
}
function isVisible(target) {
return target.offsetParent !== null;
}
function isOutsideClick(event, target, el) {
return !el.isSameNode(event.target) && !el.contains(event.target) && !target.contains(event.target);
}
const StyleClass = {
mounted(el, binding) {
bind(el, binding);