From 34e7b3cd429785c840f0f3eb38c3d597ca959926 Mon Sep 17 00:00:00 2001 From: sansiro Date: Fri, 18 Nov 2022 13:05:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20table=20itemActions=20=E5=B7=A6=E5=8F=B3?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E4=BD=8D=E7=BD=AE=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20(#5746)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: table itemActions 左右滚动位置问题修复 * 修改 * 修改 --- .../amis/src/renderers/Table/TableContent.tsx | 15 ++++++++++++--- packages/amis/src/renderers/Table/index.tsx | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/amis/src/renderers/Table/TableContent.tsx b/packages/amis/src/renderers/Table/TableContent.tsx index e62df16ab..c1455ab79 100644 --- a/packages/amis/src/renderers/Table/TableContent.tsx +++ b/packages/amis/src/renderers/Table/TableContent.tsx @@ -70,8 +70,18 @@ export interface TableContentProps extends LocaleProps { @observer export class TableContent extends React.Component { - renderItemActions() { - const {itemActions, render, store, classnames: cx} = this.props; + static renderItemActions( + props: Pick< + TableContentProps, + 'itemActions' | 'render' | 'store' | 'classnames' + > + ) { + const {itemActions, render, store, classnames: cx} = props; + + if (!store.hoverRow) { + return null; + } + const finalActions = Array.isArray(itemActions) ? itemActions.filter(action => !action.hiddenOnHover) : []; @@ -149,7 +159,6 @@ export class TableContent extends React.Component { className={cx('Table-content', className)} onScroll={onScroll} > - {store.hoverRow ? this.renderItemActions() : null} {columnsGroup.length ? ( diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index fae164942..0174d5a24 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -2805,6 +2805,12 @@ export default class Table extends React.Component { return ( <> + {TableContent.renderItemActions({ + store, + classnames: cx, + render, + itemActions + })}