fix: address review feedback - fixed height, remove redundant code, improve tests

Amp-Thread-ID: https://ampcode.com/threads/T-019c176b-ea24-74be-8443-446ec9522c03
This commit is contained in:
bymyself
2026-01-31 21:59:23 -08:00
parent 2d55582916
commit 5da228257a
3 changed files with 9 additions and 10 deletions

View File

@@ -71,11 +71,10 @@ describe('VirtualGrid', () => {
await nextTick()
if (receivedIndices.length > 0) {
expect(receivedIndices[0]).toBe(0)
for (let i = 1; i < receivedIndices.length; i++) {
expect(receivedIndices[i]).toBe(receivedIndices[i - 1] + 1)
}
expect(receivedIndices.length).toBeGreaterThan(0)
expect(receivedIndices[0]).toBe(0)
for (let i = 1; i < receivedIndices.length; i++) {
expect(receivedIndices[i]).toBe(receivedIndices[i - 1] + 1)
}
wrapper.unmount()
@@ -97,6 +96,9 @@ describe('VirtualGrid', () => {
const gridElement = wrapper.find('[style*="grid"]')
expect(gridElement.exists()).toBe(true)
const style = gridElement.attributes('style') ?? ''
expect(style).toContain('repeat(2')
wrapper.unmount()
})

View File

@@ -57,9 +57,7 @@ const emit = defineEmits<{
'approach-end': []
}>()
defineSlots<{
item: (props: { item: T & { key: string }; index: number }) => unknown
}>()
const itemHeight = ref(defaultItemHeight)
const itemWidth = ref(defaultItemWidth)

View File

@@ -64,7 +64,6 @@ const layoutConfig = computed<LayoutConfig>(
const gridStyle = computed<CSSProperties>(() => ({
display: 'grid',
gridTemplateColumns: `repeat(${layoutConfig.value.maxColumns}, 1fr)`,
gap: layoutConfig.value.gap,
padding: '1rem',
width: '100%'
@@ -81,7 +80,7 @@ const virtualItems = computed<VirtualDropdownItem[]>(() =>
<template>
<div
class="flex max-h-[640px] w-103 flex-col rounded-lg bg-component-node-background pt-4 outline outline-offset-[-1px] outline-node-component-border"
class="flex h-[640px] w-103 flex-col rounded-lg bg-component-node-background pt-4 outline outline-offset-[-1px] outline-node-component-border"
>
<!-- Filter -->
<FormDropdownMenuFilter