LearnNewsExamplesServices
Frontmatter
id1137
titlemanager.DomEvent: fire() => mouseenter & mouseleave while dragging
stateClosed
labels
enhancement
assigneestobiu
createdAtAug 28, 2020, 2:08 PM
updatedAtAug 28, 2020, 5:26 PM
githubUrlhttps://github.com/neomjs/neo/issues/1137
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtAug 28, 2020, 2:22 PM

manager.DomEvent: fire() => mouseenter & mouseleave while dragging

Closed v8.1.0 enhancement
tobiu
tobiu commented on Aug 28, 2020, 2:08 PM

This one is an interesting issue.

// we only want mouseenter & leave to fire on their top level nodes, not for children
if (eventName === 'mouseenter' || eventName === 'mouseleave') {
    targetId = eventName === 'mouseenter' ? data.fromElementId : data.toElementId;

    if (targetId && targetId !== delegationTargetId) {
        delegationVdom = VDomUtil.findVdomChild(component.vdom, delegationTargetId);

        if (delegationVdom.vdom && VDomUtil.findVdomChild(delegationVdom.vdom, targetId)) {
            preventFire = true;
        }
    }
}

E.g. for dialogs, we can drag a proxyEl over the real dialog. In this case, we get mouseenter & leave events for it. the targetId is in this case outside of the dialog, so delegationVdom can actually be undefined.

I will add a check to not fire the event(s) here.

We could enhance the main thread further => main.addon.DragDrop could fire events to let main.DomEvents know that a drag OP is in progress, in which case we could suppress specific events. Would be a follow up ticket.

tobiu added the enhancement label on Aug 28, 2020, 2:08 PM
tobiu assigned to @tobiu on Aug 28, 2020, 2:08 PM
tobiu referenced in commit f5b32af - "manager.DomEvent: fire() => mouseenter & mouseleave while dragging #1137" on Aug 28, 2020, 2:10 PM
tobiu referenced in commit c4293e1 - "#1137 manager.DomEvent: moved the logic into static verifyMouseEnterLeave()" on Aug 28, 2020, 2:21 PM
tobiu
tobiu Aug 28, 2020, 2:22 PM

moved the logic outside of the fire() method.

    /**
     *
     * @param {Neo.component.Base} component
     * @param {Object} data
     * @param {String} delegationTargetId
     * @param {String} eventName
     * @returns {Boolean}
     */
    static verifyMouseEnterLeave(component, data, delegationTargetId, eventName) {
        let targetId = eventName === 'mouseenter' ? data.fromElementId : data.toElementId,
            delegationVdom;

    if (targetId && targetId !== delegationTargetId) {
        delegationVdom = VDomUtil.findVdomChild(component.vdom, delegationTargetId);

        // delegationVdom can be undefined when dragging a proxy over the node.
        // see issues/1137 for details.
        if (!delegationVdom || delegationVdom.vdom && VDomUtil.findVdomChild(delegationVdom.vdom, targetId)) {
            return false;
        }
    }

    return true;
}

tobiu closed this issue on Aug 28, 2020, 2:22 PM