From 358e1297655039744bf675fbd9a62eb9f3c69e97 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Mon, 4 Aug 2025 18:15:18 +0800 Subject: [PATCH] feat(hooks): add scrollX computation for total table width in useNaiveTable --- src/hooks/common/table.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hooks/common/table.ts b/src/hooks/common/table.ts index 0b36e00c..0c943f58 100644 --- a/src/hooks/common/table.ts +++ b/src/hooks/common/table.ts @@ -38,6 +38,13 @@ export function useNaiveTable(options: UseNaiveTableOptio getColumns }); + // calculate the total width of the table this is used for horizontal scrolling + const scrollX = computed(() => { + return result.columns.value.reduce((acc, column) => { + return acc + Number(column.width ?? column.minWidth ?? 120); + }, 0); + }); + scope.run(() => { watch( () => appStore.locale, @@ -51,7 +58,10 @@ export function useNaiveTable(options: UseNaiveTableOptio scope.stop(); }); - return result; + return { + ...result, + scrollX + }; } type PaginationParams = Pick;