Fix modal isOpen not updating correctly

This commit is contained in:
Robbie Antenesse 2019-09-16 12:08:37 -06:00
parent d3d35bacc8
commit 7deda1c835
1 changed files with 3 additions and 3 deletions

View File

@ -14,7 +14,7 @@ export const modal = (modalId, controller, contentHTML, options = {}) => {
* onHide <function>: Runs when the modal closes. * onHide <function>: Runs when the modal closes.
*/ */
const isOpen = controller.openModal === modalId; const isOpen = () => controller.openModal === modalId;
return [ return [
( (
@ -25,8 +25,8 @@ export const modal = (modalId, controller, contentHTML, options = {}) => {
// Modals in Picnic CSS uses pure CSS with clever usage of invisible checkboxes and labels // Modals in Picnic CSS uses pure CSS with clever usage of invisible checkboxes and labels
html`<div class="modal"> html`<div class="modal">
<input id=${modalId} type="checkbox" ${isOpen ? 'checked' : null} onchange=${event => { <input id=${modalId} type="checkbox" ${isOpen() ? 'checked' : null} onchange=${event => {
controller.openModal = !isOpen ? modalId : null; // If it's not already open, set it to the open one controller.openModal = !isOpen() ? modalId : null; // If it's not already open, set it to the open one
if (typeof options.onShow !== 'undefined' && event.target.checked) { if (typeof options.onShow !== 'undefined' && event.target.checked) {
options.onShow(); options.onShow();
} }