diff --git a/kitchen-sink/vue/src/pages/smart-select.vue b/kitchen-sink/vue/src/pages/smart-select.vue index ac0b8b2a5a..761ffeee26 100644 --- a/kitchen-sink/vue/src/pages/smart-select.vue +++ b/kitchen-sink/vue/src/pages/smart-select.vue @@ -66,18 +66,84 @@ + + Vue Model + + + + + + + + + + + + + + + + + diff --git a/src/vue/components/list-item.vue b/src/vue/components/list-item.vue index 646a47f6be..33b9dcc0eb 100644 --- a/src/vue/components/list-item.vue +++ b/src/vue/components/list-item.vue @@ -227,6 +227,7 @@ export default { // Smart Select smartSelect: Boolean, smartSelectParams: Object, + smartSelection: [String, Number, Array, Date, Object], // Links Chevron (Arrow) Icon noChevron: Boolean, @@ -271,6 +272,7 @@ export default { 'accordion:opened', 'change', 'update:checked', + 'update:smartSelection', ], setup(props, { slots, emit }) { const ListContext = inject('ListContext', { @@ -362,17 +364,40 @@ export default { emit('change', event); emit('update:checked', event.target.checked); }; + const onSmartSelectChange = (ss, value) => { + emit('update:smartSelection', value); + }; useTooltip(elRef, props); useRouteProps(linkElRef, props); + let f7SmartSelect = null; useSmartSelect( props, - () => {}, + (instance) => { + f7SmartSelect = instance; + if (f7SmartSelect) { + if (props.smartSelection !== undefined) { + f7SmartSelect.setValue(props.smartSelection); + } + // register for change event only after setting initial value + f7SmartSelect.$el.on('smartselect:change', onSmartSelectChange); + } + }, () => elRef.value.querySelector('a.smart-select'), ); + watch( + () => props.smartSelection, + (newValue) => { + // eslint-disable-next-line eqeqeq + if (newValue === undefined || !f7SmartSelect || f7SmartSelect.getValue() == newValue) + return; + f7SmartSelect.setValue(newValue); + }, + ); + watch( () => props.swipeoutOpened, (newValue) => {