bugfix: MD Select needs to call _bb apis
This commit is contained in:
parent
3ebec70084
commit
c37938f4d4
|
@ -28,18 +28,30 @@
|
||||||
export let label = ""
|
export let label = ""
|
||||||
export let helperText = ""
|
export let helperText = ""
|
||||||
export let persistent = false
|
export let persistent = false
|
||||||
|
export let value = ""
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
_bb.setContext("BBMD:list:props", { singleSelection: true })
|
_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)
|
_bb.setContext("BBMD:list:selectItemStore", selectedItemsStore)
|
||||||
|
|
||||||
_helperId = generate()
|
_helperId = generate()
|
||||||
|
|
||||||
if (!!select) {
|
if (!!select) {
|
||||||
instance = new MDCSelect(select)
|
instance = new MDCSelect(select)
|
||||||
debugger
|
|
||||||
return () => {
|
return () => {
|
||||||
instance && instance.destroy()
|
instance && instance.destroy()
|
||||||
instance = null
|
instance = null
|
||||||
|
@ -53,6 +65,9 @@
|
||||||
$: modifiers = { variant, disabled, required, noLabel: !label }
|
$: modifiers = { variant, disabled, required, noLabel: !label }
|
||||||
$: props = { modifiers }
|
$: props = { modifiers }
|
||||||
$: selectClass = cb.build({ props })
|
$: selectClass = cb.build({ props })
|
||||||
|
$: if (value !== undefined && selectedItemsStore) {
|
||||||
|
selectedItemsStore.addSingleItem(value)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={select} id={_helperId} class={selectClass}>
|
<div bind:this={select} id={_helperId} class={selectClass}>
|
||||||
|
|
Loading…
Reference in New Issue