From 2fd5b93c8a0a8d330977d4c7c0ee692349cb136e Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 27 Feb 2020 23:41:36 +0000 Subject: [PATCH] bugfix: MD checkbox throwing --- .../src/Checkbox/Checkbox.svelte | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/materialdesign-components/src/Checkbox/Checkbox.svelte b/packages/materialdesign-components/src/Checkbox/Checkbox.svelte index 2f8b55bcf2..ceced6af9c 100644 --- a/packages/materialdesign-components/src/Checkbox/Checkbox.svelte +++ b/packages/materialdesign-components/src/Checkbox/Checkbox.svelte @@ -27,7 +27,8 @@ if (context !== "list-item") { //TODO: Fix this connected to Formfield context issue let fieldStore = _bb.getContext("BBMD:field-element") - fieldStore.setInput(instance) + if(fieldStore) + fieldStore.setInput(instance) } } }) @@ -43,6 +44,14 @@ let props = { modifiers, extras } const blockClass = cb.build({ props }) + + function changed(e) { + const val = e.target.checked + checked = val + if (_bb.isBound(_bb.props.checked)) { + _bb.setStateFromBinding(_bb.props.checked, val) + } + } @@ -56,7 +65,8 @@ {id} {disabled} {checked} - on:click={onClick} /> + on:click={onClick} + on:change={changed} />