Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 补齐数据表横向覆盖式滑块

longmeidaoab94959cf8f1
diff --git a/frontend/e2e/orphan-table.test.ts b/frontend/e2e/orphan-table.test.ts
index 3b6c93c2b..43b663acf 100644
--- a/frontend/e2e/orphan-table.test.ts
+++ b/frontend/e2e/orphan-table.test.ts
@@ -30,6 +30,22 @@ describe('孤儿记录数据表', () => {
const table = page.getByRole('grid', { name: '文件已消失的作品', exact: true });
await table.waitFor();
await settle(page);
+ const scroller = table.locator('..');
+ assert.equal(await scroller.getAttribute('data-overlay-scrollbar'), 'true');
+ if (viewport.mobile) {
+ const track = section.locator('[data-board-data-table] > .ov-x');
+ await track.waitFor({ state: 'visible' });
+ const before = await track.locator('.ovthumb').evaluate(node => getComputedStyle(node).transform);
+ await scroller.evaluate(node => { node.scrollLeft = node.scrollWidth });
+ await page.waitForFunction(() => {
+ const node = document.querySelector('#orphan-records [data-overlay-scrollbar]')!;
+ return node.scrollLeft > 0;
+ });
+ await settle(page);
+ const after = await track.locator('.ovthumb').evaluate(node => getComputedStyle(node).transform);
+ assert.notEqual(after, before, '横向滑块没有跟随表格滚动');
+ await scroller.evaluate(node => { node.scrollLeft = 0 });
+ }
assert.equal(await section.locator('[data-data-table-panel] #orphan-records-title').count(), 1);
assert.equal(await table.locator('tbody tr').count(), 20);
assert.equal(await section.getByRole('button', { name: '彻底删除所选(0)', exact: true }).count(), 0);
diff --git a/frontend/src/react/components/data-table-frame.tsx b/frontend/src/react/components/data-table-frame.tsx
index 1d240c73d..01f01ba9b 100644
--- a/frontend/src/react/components/data-table-frame.tsx
+++ b/frontend/src/react/components/data-table-frame.tsx
@@ -1,4 +1,5 @@
-import type { MouseEvent, PropsWithChildren } from 'react';
+import { useEffect, useRef, type MouseEvent, type PropsWithChildren } from 'react';
+import { attachOverlayScrollbar } from '@peach/legacy/ui';
import { clickedBlank } from './row-click';
@@ -12,6 +13,10 @@ export interface DataTableFrameProps extends PropsWithChildren {
/** BoardUI Table 的 Data Table 外框:主表面、完整边线、圆角与选中行反馈。 */
export function DataTableFrame({ children, follow = false, onRowClick }: DataTableFrameProps) {
+ const host = useRef<HTMLDivElement>(null);
+ useEffect(() => {
+ attachOverlayScrollbar(host.current?.querySelector<HTMLElement>(':scope > .overflow-x-auto') ?? null);
+ });
const click = onRowClick ? (event: MouseEvent<HTMLDivElement>) => {
const target = event.target;
if (!(target instanceof Element)) return;
@@ -19,7 +24,7 @@ export function DataTableFrame({ children, follow = false, onRowClick }: DataTab
if (row && clickedBlank(event, row)) onRowClick(row.dataset.key!);
} : undefined;
return (
- <div data-board-data-table data-follow-table={follow || undefined} onClick={click}>
+ <div ref={host} data-board-data-table data-follow-table={follow || undefined} onClick={click}>
{children}
</div>
);
diff --git a/web/dist/peach-app.js b/web/dist/peach-app.js
index e6e3f8eae..eaf336915 100644
--- a/web/dist/peach-app.js
+++ b/web/dist/peach-app.js
@@ -53362,7 +53362,11 @@ function xR({ size: e = "md", className: t, containerClassName: n, ref: r, ...i
//#endregion
//#region src/react/components/data-table-frame.tsx
function SR({ children: e, follow: t = !1, onRowClick: n }) {
- return /* @__PURE__ */ (0, C.jsx)("div", {
+ let r = (0, S.useRef)(null);
+ return (0, S.useEffect)(() => {
+ Na(r.current?.querySelector(":scope > .overflow-x-auto") ?? null);
+ }), /* @__PURE__ */ (0, C.jsx)("div", {
+ ref: r,
"data-board-data-table": !0,
"data-follow-table": t || void 0,
onClick: n ? (e) => {