From c37938f4d4ee87cd444a39f3466ead50038af10e Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Wed, 4 Mar 2020 16:50:35 +0000 Subject: [PATCH] bugfix: MD Select needs to call _bb apis --- .../src/Select/Select.svelte | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/materialdesign-components/src/Select/Select.svelte b/packages/materialdesign-components/src/Select/Select.svelte index 28cf58697f..e6bf7c9e01 100644 --- a/packages/materialdesign-components/src/Select/Select.svelte +++ b/packages/materialdesign-components/src/Select/Select.svelte @@ -28,18 +28,30 @@ export let label = "" export let helperText = "" export let persistent = false + export let value = "" onMount(() => { _bb.setContext("BBMD:list:props", { singleSelection: true }) - selectedItemsStore = createItemsStore(() => onSelect($selectedItemsStore)) + const setValue = v => { + _bb.setStateFromBinding(_bb.props.value, v) + value = v + } + selectedItemsStore = createItemsStore(() => { + + if($selectedItemsStore && $selectedItemsStore.length > 0) + setValue($selectedItemsStore[0].value) + else + setValue("") + + _bb.call(onSelect, $selectedItemsStore) + }) _bb.setContext("BBMD:list:selectItemStore", selectedItemsStore) _helperId = generate() if (!!select) { instance = new MDCSelect(select) - debugger return () => { instance && instance.destroy() instance = null @@ -53,6 +65,9 @@ $: modifiers = { variant, disabled, required, noLabel: !label } $: props = { modifiers } $: selectClass = cb.build({ props }) + $: if (value !== undefined && selectedItemsStore) { + selectedItemsStore.addSingleItem(value) + }