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 1674048
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/analytics/dashboard-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"extends": "../../../package.json"
},
"distSizeChecker": {
"errorLimit": "512KB"
"errorLimit": "600KB"
},
"peerDependencies": {
"@kong-ui-public/analytics-chart": "workspace:^",
Expand Down
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 @@ -27,7 +27,7 @@
<script lang='ts' setup generic="T">
import { onMounted, onUnmounted, ref, watch, nextTick } from 'vue'
import { GridStack } from 'gridstack'
import type { GridStackElement, GridStackNode } from 'gridstack'
import type { GridStackNode } from 'gridstack'
import type { GridSize, GridTile } from 'src/types'
import 'gridstack/dist/gridstack.min.css'
import 'gridstack/dist/gridstack-extra.min.css'
Expand Down 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 1674048

Please sign in to comment.