Fix new block y position
This commit is contained in:
@@ -125,8 +125,8 @@ export default {
|
||||
return meta.hidden ? { i, x: 0, y: 0, w: 0, h: 0 } : { i, x, y, w, h }
|
||||
})
|
||||
|
||||
// Only use next tick if previous layout exists
|
||||
if (this.layout.length) {
|
||||
// Only use next tick if previous layout exists and not editing
|
||||
if (this.layout.length && !this.editable) {
|
||||
this.layout = []
|
||||
|
||||
// Next tick is important, otherwise it can lead to overlapping blocks
|
||||
|
||||
@@ -526,6 +526,7 @@ export default {
|
||||
|
||||
addBlock (block, index = undefined) {
|
||||
this.$bvModal.hide('createBlockSelector')
|
||||
this.calculateNewBlockPosition(block)
|
||||
this.editor = { index, block: compose.PageBlockMaker(block) }
|
||||
},
|
||||
|
||||
@@ -604,6 +605,7 @@ export default {
|
||||
} else {
|
||||
this.blocks.push(block)
|
||||
this.unsavedBlocks.add(this.blocks.length - 1)
|
||||
this.scrollToBottom()
|
||||
}
|
||||
|
||||
if (block.kind === 'Tabs') {
|
||||
@@ -912,6 +914,17 @@ export default {
|
||||
this.$refs.layoutSelect.localValue = this.layout.pageLayoutID
|
||||
})
|
||||
},
|
||||
|
||||
scrollToBottom () {
|
||||
const pageBuilderElement = document.getElementById('page-builder')
|
||||
|
||||
this.$nextTick(() => {
|
||||
pageBuilderElement.scrollTo({
|
||||
top: pageBuilderElement.scrollHeight,
|
||||
behavior: 'smooth',
|
||||
})
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user