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

mouseUp on overlay is closing modal #303

Open
VascoRatoFCCN opened this issue Nov 19, 2021 · 0 comments
Open

mouseUp on overlay is closing modal #303

VascoRatoFCCN opened this issue Nov 19, 2021 · 0 comments

Comments

@VascoRatoFCCN
Copy link

Recently I was selecting some text on a modal and ended up with the mouse cursor outside the modal. To my surprise, this closed the modal! You can test this behavior on the first example on the jQuery modal website:

image

In my eyes this is an undesired behavior, and it could be easily fixed by changing the following code (line 100 on jquery.modal.js):

if (this.options.clickClose)
        this.$blocker.click(function(e) {
          if (e.target === this)
            $.modal.close();
        });

with something like this:

if (this.options.clickClose) {
    if (!this.$blocker.properties) {
        this.$blocker.properties = {};
    }
    this.$blocker.properties.mousedown = false;
    this.$blocker.off('mousedown').on('mousedown', function (e) {
        if (e.target === this){
            m.$blocker.properties.mousedown = true;
        }
    });
    this.$blocker.off('mouseup').on('mouseup', function (e) {
        if (e.target === this && m.$blocker.properties.mousedown) {
            $.modal.close();
        } else {
            m.$blocker.properties.mousedown = false;
        }
    });
}

My code isn't very elegant but does the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant