Skip to content

Commit

Permalink
fix(metaComponent): fix opentiny#79 metaListItems dragging not working
Browse files Browse the repository at this point in the history
  • Loading branch information
chilingling committed Nov 16, 2023
1 parent 9be6f31 commit f6b0e5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions packages/common/component/MetaContainer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<meta-list-items class="list" :optionsList="children">
<meta-list-items class="list" :optionsList="children" @dragEnd="dragEnd">
<template #content="{ data }">
<div class="item-text">
<div class="tiny-input">
Expand Down Expand Up @@ -67,7 +67,21 @@ export default {
useHistory().addHistory()
}
return { children, addChildren, delChildren }
const dragEnd = (params = {}) => {
const { oldIndex, newIndex } = params?.moved || {}
if (oldIndex === undefined || newIndex === undefined) {
return
}
const list = schemaChildren
const spliceItem = list.splice(oldIndex, 1)
list.splice(newIndex, 0, ...spliceItem)
children.value = [...list]
}
return { children, addChildren, delChildren, dragEnd }
}
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions packages/common/component/MetaListItems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export default {
emit('deleteItem', params)
}
const dragEnd = () => {
emit('changeItem')
const dragEnd = (value) => {
emit('dragEnd', value)
}
const editItem = (params) => {
Expand Down

0 comments on commit f6b0e5f

Please sign in to comment.