Question: I have a website where the user will be able to see charts created based on filters that they have chosen. At the top of the page are several filter topics that, when clicked, expand a sort of dialog underneath (I am actually perverting Bootstrap's dropdown element for this purpose for the moment) where they can make specific choice (e.g., region, gender, etc., and some slightly more complex ones).

The dialog will have two buttons at the bottom, "OK" and "Cancel" - if you hit OK, the dialog closes and shows an abbreviated version of your selections under the filter label; and if you hit Cancel, the dialog closes and reverts to whatever the filter was at originally (that is, before your latest changes that you "canceled"). Then there is a button to trigger implementation of the filters you've chosen and change the charts.

However, the default behavior of these dialogs (and something that I think a lot of users probably expect, but I could be wrong) also allows people to close the dialog by "clicking off" - that is, clicking the page somewhere outside of the dialog box. 

The question we have is: should this behavior trigger "OK" or "Cancel"? Or maybe we should disallow this behavior altogether and force them to choose one of the buttons in order to close the dialog.

I was thinking I would expect that the next time I opened the dialog, it would show the selections I had made unless I clicked cancel (kind of like how in some browsers, if you are filling out a form and click a link off of the page, but then use the back button, you find your answers still filled in). My colleague expected this behavior to cancel whatever was put in. I think we are too close to this so I appreciate any feedback. Thank you.

Answer: 
In this case it is wise to stick to conventions; clicking outside of a modal will act the same as the cancel option. Enabling this behaviour will help people who rely on this principle on other websites, while not harming those who never use it.

Remember, it's a good thing to label your call to actions appropriately - OK and Cancel are context dependant. They force a user to read everything before these actions make sense (and even then it can be dubious what lies beyond the click). 

[In regards to accessability: This link contains examples for how it works.](https://www.w3.org/WAI/GL/wiki/Using_ARIA_role%3Ddialog_to_implement_a_modal_dialog_box#Example_1:_A_button_opens_a_custom_dialog) And here is a [demo](http://www.humaan.com/modaal/). This helps both people that navigate through keyboard and people who like to click out of the window to close things. It's very user friendly.
It should act as a "Cancel". You could disable that feature and be perfectly fine, as long as their keyboard focus and clicking behavior is trapped within the modal; forcing them to choose either "Ok" or "Cancel". It is imperative to lock their focus specifically for Accessibility reasons. 

I also wouldn't remember any previous selections. The term "Cancel" means to act as if I did nothing.

For Web pages, you should read up on the [WAI-ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal) concerning Modals.