Skip to content

Commit

Permalink
fix: handle remove
Browse files Browse the repository at this point in the history
  • Loading branch information
filipgutica committed Feb 11, 2025
1 parent c1da971 commit c268a88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ const addTile = () => {
const onRemoveTile = (tile: GridTile<TileDefinition>) => {
console.log('@remove-tile', tile)
console.log('before:', dashboardConfig.value.tiles.length)
dashboardConfig.value.tiles = dashboardConfig.value.tiles.filter((_, i) => i !== tile.id)
console.log('after:', dashboardConfig.value.tiles.length)
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,8 @@ watch(() => props.tiles.length, async (newLen, oldLen) => {
})
grid.load(nodesToAdd)
} else if (newLen < oldLen && grid) {
const tileToRemove = props.tiles.slice(newLen)
const elementsToRemove = tileToRemove.map(e => {
return gridContainer.value?.querySelector(`[data-id="${e.id}"]`) as GridStackElement
})
elementsToRemove.forEach(e => {
grid?.removeWidget(e)
})
await nextTick()
grid.compact()
}
})
</script>
Expand Down

0 comments on commit c268a88

Please sign in to comment.