Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tpto
Copy link
Contributor

@tpto tpto commented Feb 28, 2025

What

修复表格开启整行选择(rowSelection.rowClick)后,点击单选或复选框无响应

Why

当前效果:

2025-02-28 11 34 24

修改后的效果:

2025-02-28 11 42 46

How

Row.tsx组件中的onClick事件做了限制(修复是 在这里扩展了一个配置,不影响之前逻辑)

// packages/amis-ui/src/components/table/Row.tsx

  onClick(
    e: React.MouseEvent<HTMLTableRowElement>,
    record?: any,
    rowIndex?: number
  ) {
    if (isClickOnInput(e)) {
      return;
    }

    const {onClick} = this.props;
    onClick && onClick(e, record, rowIndex);
  }

另一个原因是:

checkbox的onChange到table的onRowChange中被拦截

// packages/amis-ui/src/components/table/index.tsx

  onRowChange(value: boolean, record: any) {
    const {rowSelection} = this.props;
    if (!(rowSelection && rowSelection.rowClick)) {
      this.selectedSingleRow(value, record);
    }
  }

同时isClickOnInput也影响onEvent. rowClick

2025-02-28 11 48 18

@github-actions
Copy link

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

@github-actions github-actions bot added the fix label Feb 28, 2025
@2betop 2betop merged commit ab068f6 into baidu:master Apr 3, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants