Skip to content

Commit

Permalink
Ensure hidden blocks aren't hidden forever
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmyMay committed May 31, 2023
1 parent 0fcbec0 commit c939015
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
14 changes: 9 additions & 5 deletions client/web/compose/src/components/PageBlocks/TabsBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,18 @@ export default {
computed: {
tabbedBlocks () {
return this.block.options.tabs.map(({ blockID, title }) => {
let block = this.blocks.find(b => fetchID(b) === blockID)
const unparsedBlock = this.blocks.find(b => fetchID(b) === blockID)
// Blocks should display as Plain, to avoid card shadow/border
if (block) {
block.style.wrap.kind = 'Plain'
block = compose.PageBlockMaker(block)
if (!unparsedBlock) {
return { title }
}
let block = JSON.parse(JSON.stringify(unparsedBlock))
// Blocks should display as Plain, to avoid card shadow/border
block.style.wrap.kind = 'Plain'
block.style.border.enabled = false
block = compose.PageBlockMaker(block)
return {
block,
title,
Expand Down
23 changes: 22 additions & 1 deletion client/web/compose/src/views/Admin/Pages/Builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ export default {
if (oldBlock.meta.hidden === true && this.editor.block.meta.hidden === false) {
this.untabBlock(this.editor.block)
this.calculateNewBlockPosition(block)
block.style.wrap.kind = 'Card'
}
this.blocks.splice(this.editor.index, 1, block)
Expand All @@ -623,13 +622,35 @@ export default {
tabbedBlock.meta.hidden = true
})
this.showUnusedHiddenBlocks()
}
if (this.editor.block.kind === block.kind) {
this.editor = undefined
}
},
showUnusedHiddenBlocks () {
const allTabBlocks = this.blocks.filter(({ kind }) => kind === 'Tabs')
this.blocks.forEach(block => {
if (!block.meta.hidden) return
const hiddenBlockID = fetchID(block)
// Go through all hidden blocks to see if they are tabbed anywhere
const tabbed = allTabBlocks.some(({ options }) => {
const { tabs = [] } = options
return tabs.some(({ blockID }) => blockID === hiddenBlockID)
})
if (!tabbed) {
this.calculateNewBlockPosition(block)
block.meta.hidden = false
}
})
},
cloneBlock (index) {
this.appendBlock(this.blocks[index].clone(), this.$t('notification:page.cloneSuccess'))
},
Expand Down

0 comments on commit c939015

Please sign in to comment.