feat(modal): add preventCloseOnClickOutside prop

Closes #266
This commit is contained in:
Eric Liu 2020-09-19 09:37:36 -07:00
commit e75be23a49
4 changed files with 22 additions and 2 deletions

View file

@ -89,6 +89,12 @@
*/
export let selectorPrimaryFocus = "[data-modal-primary-focus]";
/**
* Set to `true` to prevent the modal from closing when clicking outside
* @type {boolean} [preventCloseOnClickOutside=false]
*/
export let preventCloseOnClickOutside = false;
/**
* Set an id for the top-level element
* @type {string} [id]
@ -167,7 +173,7 @@
}}"
on:click
on:click="{() => {
if (!didClickInnerModal) open = false;
if (!didClickInnerModal && !preventCloseOnClickOutside) open = false;
didClickInnerModal = false;
}}"
on:mouseover