automat/controlkit.js

Specifying parentDocumentElementID prevents mouseevents from reaching the parent

Opened this issue · 0 comments

sudsy commented

I noticed this behaviour while implementing controlKit.

I have found a fix which involves changing:

    if (!options.parentDomElementId) {
        node = new Node();
        document.body.appendChild(node.getElement());
    } else {
        node = Node.getNodeById(options.parentDomElementId);
    }

to

    if (!options.parentDomElementId) {
        node = new Node();
        document.body.appendChild(node.getElement());
    } else {
	node = new Node();
        document.getElementById(options.parentDomElementId).appendChild(node.getElement());
    }

Ideally though, I would like it to be something more like this to allow a domElement to be passed rather than referenced by id

    var rootElement = document.body;
    if (options.parentDomElement) {
        rootElement = options.parentDomElement
    } else if(options.parentDomElementId){
        rootElement = document.getElementById(options.parentDomElementId)
    }
    node = new Node();
    rootElement.appendChild(node.getElement());

I will make these changes in my own fork and will submit a PR if you would like to merge the changes.