Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复表格开启整行选择后,点击单选或复选框无响应 #11675

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

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
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.

1 participant