HubSpot / vex

A modern dialog library which is highly configurable and easy to style. #hubspot-open-source
http://github.hubspot.com/vex/docs/welcome
MIT License
6.92k stars 493 forks source link

Question: How to prevent vex from closing without using the buttons #195

Closed clarkey closed 7 years ago

clarkey commented 7 years ago

Is it possible to prevent vex from closing by hitting ESC or clicking outside the dialog?

bbatliner commented 7 years ago

Yes! There are two options that you can pass to vex.open to achieve the behavior you described:

Here is a link to the relevant documentation: http://github.hubspot.com/vex/api/advanced/#options

clarkey commented 7 years ago

@bbatliner thanks!

ffd8 commented 4 years ago

Found this issue while trying to keep the vex dialog from closing if I dragged my mouse from the dialog to outside of it and let go (fired a 'click'). There's a few situations that caused this to occur.. so I've changed it to only close the vex instance with a mousedown instead of click. Didn't want to disable with overlayClosesOnClick, just change to a mousedown instead. Might be useful to others out there:

In vex.combined.min.js, replaced the following: g.overlayClosesOnClick&&y.addEventListener("click" with g.overlayClosesOnClick&&y.addEventListener("mousedown"

Incase this causes any other weird issues.. like scrolling window for a very long vex message, I use the unsafeMessage attribute with a div with the folllowing class vex-long, which is defined as such:

.vex-long{
    width:100%;
    height:50vh;
    border-bottom:1px solid #aaa;
    max-height:70vh;
    overflow-y:auto;
    padding-bottom:10px;
    font-size:10pt;
    background:none;
    padding:5px;
    box-sizing: border-box;
    outline:none;
}