-
+
-
![Tile]()
+
-
{{ tile.data.name }}
+
{{ tile.name }}
@@ -56,28 +62,31 @@ const handleFileUpload = (e: Event) => {
}
const handleSearch = () => {
- // The filtering is handled by the computed property, so we don't need to do anything here
- // This function is kept in case you want to add debounce or other functionality later
+ // Trigger a re-render of the virtual list
+ virtualList.value?.scrollTo(0)
}
const filteredTiles = computed(() => {
if (!searchQuery.value) {
return assetManagerStore.tileList
}
- return assetManagerStore.tileList.filter((tile) => tile.name.toLowerCase().includes(searchQuery.value.toLowerCase()))
+ return assetManagerStore.tileList.filter((tile) =>
+ tile.name.toLowerCase().includes(searchQuery.value.toLowerCase())
+ )
})
-const { list, containerProps, wrapperProps } = useVirtualList(
+const { list, containerProps, wrapperProps, scrollTo } = useVirtualList(
filteredTiles,
{
- // Keep `itemHeight` in sync with the item's row.
itemHeight: 28,
},
)
+const virtualList = ref({ scrollTo })
+
onMounted(() => {
gameStore.connection?.emit('gm:tile:list', {}, (response: Tile[]) => {
assetManagerStore.setTileList(response)
})
})
-
+
\ No newline at end of file
diff --git a/src/stores/assetManager.ts b/src/stores/assetManager.ts
index eeba5d3..b1f2c5a 100644
--- a/src/stores/assetManager.ts
+++ b/src/stores/assetManager.ts
@@ -1,6 +1,6 @@
import { ref } from 'vue'
import { defineStore } from 'pinia'
-import type { Tile, Object } from '@/types'
+import type { Tile, Object, Sprite } from '@/types'
export const useAssetManagerStore = defineStore('assetManager', () => {
const tileList = ref
([])
@@ -9,30 +9,45 @@ export const useAssetManagerStore = defineStore('assetManager', () => {
const objectList = ref