From f3d53fbf7e8fb8b83dc64360db6b1bc9c9ed86f8 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Thu, 23 Nov 2023 19:19:06 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E8=B0=83=E6=95=B4=20table=20=E5=9B=BA?= =?UTF-8?q?=E9=A1=B6=E6=A8=A1=E5=BC=8F=E7=9A=84=E6=A0=B7=E5=BC=8F=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=20safari=20Close:=20#8708=20(#8863)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/store/table.ts | 11 ++++---- packages/amis-ui/scss/components/_table.scss | 8 ++++-- .../__snapshots__/crud.test.tsx.snap | 6 ++--- .../__snapshots__/inputTable.test.tsx.snap | 10 +++---- .../__snapshots__/CRUD.test.tsx.snap | 6 ++--- .../__snapshots__/Pagination.test.tsx.snap | 2 +- .../__snapshots__/Table.test.tsx.snap | 26 +++++++++---------- .../renderers/Table/ItemActionsWrapper.tsx | 5 +++- packages/amis/src/renderers/Table/index.tsx | 4 +++ 9 files changed, 45 insertions(+), 33 deletions(-) diff --git a/packages/amis-core/src/store/table.ts b/packages/amis-core/src/store/table.ts index 89123a711..1305208c1 100644 --- a/packages/amis-core/src/store/table.ts +++ b/packages/amis-core/src/store/table.ts @@ -528,7 +528,8 @@ export const TableStore = iRendererStore exportExcelLoading: false, searchFormExpanded: false, // 用来控制搜索框是否展开了,那个自动根据 searchable 生成的表单 autoGenerateFilter lazyRenderAfter: 100, - tableLayout: 'auto' + tableLayout: 'auto', + theadHeight: 0 }) .views(self => { function getColumnsExceptBuiltinTypes() { @@ -1001,7 +1002,7 @@ export const TableStore = iRendererStore }, buildStyles(style: any) { - style = {...style}; + style = {...style, '--Table-thead-height': self.theadHeight + 'px'}; getFilteredColumns().forEach(column => { style[`--Table-column-${column.index}-width`] = @@ -1295,9 +1296,9 @@ export const TableStore = iRendererStore if (!table) { return; } - const cols = [].slice.call( - table.querySelectorAll(':scope>thead>tr>th[data-index]') - ); + const thead = table.querySelector(':scope>thead') as HTMLElement; + const cols = [].slice.call(thead.querySelectorAll('tr>th[data-index]')); + self.theadHeight = thead.offsetHeight; cols.forEach((col: HTMLElement) => { const index = parseInt(col.getAttribute('data-index')!, 10); const column = self.columns[index]; diff --git a/packages/amis-ui/scss/components/_table.scss b/packages/amis-ui/scss/components/_table.scss index 8ec35a319..95c280978 100644 --- a/packages/amis-ui/scss/components/_table.scss +++ b/packages/amis-ui/scss/components/_table.scss @@ -273,8 +273,12 @@ padding-top: 0; } - &--affixHeader > thead { - visibility: collapse; + &--affixHeader { + margin-top: calc(var(--Table-thead-height) * -1); + + > thead { + visibility: hidden; + } } &--withCombine { diff --git a/packages/amis/__tests__/event-action/renderers/__snapshots__/crud.test.tsx.snap b/packages/amis/__tests__/event-action/renderers/__snapshots__/crud.test.tsx.snap index 92e7c7509..c6ebf2d0f 100644 --- a/packages/amis/__tests__/event-action/renderers/__snapshots__/crud.test.tsx.snap +++ b/packages/amis/__tests__/event-action/renderers/__snapshots__/crud.test.tsx.snap @@ -28,7 +28,7 @@ exports[`doAction:crud reload 1`] = ` >
{ document.addEventListener('mousemove', this.handleColResizeMouseMove); document.addEventListener('mouseup', this.handleColResizeMouseUp); + + // 防止选中文本 + e.preventDefault(); + e.stopPropagation(); } // 垂直线拖拽移动