improve DataTableLayout scrolling behavior

This commit is contained in:
pa
2026-01-20 22:34:08 +09:00
committed by Natsumi
parent ded6b0ccf0
commit ecbb0612ec
2 changed files with 11 additions and 2 deletions

View File

@@ -37,6 +37,7 @@
return; return;
} }
} }
if (!fileId) return;
image.value = await getCachedEmoji(fileId); image.value = await getCachedEmoji(fileId);
} }

View File

@@ -5,7 +5,7 @@
</div> </div>
<div class="rounded-md border"> <div class="rounded-md border">
<div class="max-w-full overflow-auto relative" :style="tableStyle"> <div ref="tableScrollRef" class="max-w-full overflow-auto relative" :style="tableStyle">
<Table :class="tableClassValue" :style="tableElementStyle"> <Table :class="tableClassValue" :style="tableElementStyle">
<colgroup> <colgroup>
<col v-for="col in table.getVisibleLeafColumns()" :key="col.id" :style="getColStyle(col)" /> <col v-for="col in table.getVisibleLeafColumns()" :key="col.id" :style="getColStyle(col)" />
@@ -116,9 +116,9 @@
</template> </template>
<script setup> <script setup>
import { computed, nextTick, ref, watch } from 'vue';
import { FlexRender } from '@tanstack/vue-table'; import { FlexRender } from '@tanstack/vue-table';
import { Spinner } from '@/components/ui/spinner'; import { Spinner } from '@/components/ui/spinner';
import { computed } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useAppearanceSettingsStore } from '@/stores/'; import { useAppearanceSettingsStore } from '@/stores/';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
@@ -185,6 +185,7 @@
}); });
const { t } = useI18n(); const { t } = useI18n();
const tableScrollRef = ref(null);
const expandedRenderer = computed(() => { const expandedRenderer = computed(() => {
const columns = props.table.getAllColumns?.() ?? []; const columns = props.table.getAllColumns?.() ?? [];
@@ -319,6 +320,13 @@
} }
}); });
watch([currentPage, pageSizeProxy], async () => {
await nextTick();
if (tableScrollRef.value) {
tableScrollRef.value.scrollTop = 0;
}
});
const handleRowClick = (row) => { const handleRowClick = (row) => {
if (!props.onRowClick) return; if (!props.onRowClick) return;
props.onRowClick(row); props.onRowClick(row);