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: expandable.expandIconColumnIndex setting failure in version 4.0 #21315

Merged
merged 2 commits into from Feb 10, 2020

Conversation

fomenyesu
Copy link
Contributor

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

#17942

💡 Background and solution

4.0版本下的 expandable.expandIconColumnIndex 设置会被覆盖掉。3.x版本没有这个问题。对比源码发现3.x版本判断了用户设置里是否自定义里expandIconColumnIndex,而4.0版本expandIconColumnIndex设置方式有误,没有做判断。会覆盖掉用户设置的expandIconColumnIndex。

3.x 代码片段:

    let expandIconColumnIndex = columns[0] && columns[0].key === 'selection-column' ? 1 : 0;
    if ('expandIconColumnIndex' in restProps) {
      expandIconColumnIndex = restProps.expandIconColumnIndex as number;
    }

4.0 代码片段:

  // ========================== Expandable ==========================
  const mergedExpandable: ExpandableConfig<RecordType> = {
    ...expandable,
  };
...
  // Adjust expand icon index
  if (expandType === 'nest') {
    mergedExpandable.expandIconColumnIndex = rowSelection ? 1 : 0;
  }

修改后:

  // ========================== Expandable ==========================
  const mergedExpandable: ExpandableConfig<RecordType> = {
    ...expandable,
  };
...
  // Adjust expand icon index, no overwrite expandIconColumnIndex if set.
  if (expandType === 'nest' && !('expandIconColumnIndex' in mergedExpandable)) {
    mergedExpandable.expandIconColumnIndex = rowSelection ? 1 : 0;
  }

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@ant-design-bot
Copy link
Contributor

ant-design-bot commented Feb 10, 2020

@yoyo837 yoyo837 requested a review from zombieJ February 10, 2020 06:32
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 275c09a:

Sandbox Source
antd reproduction template Configuration

@zombieJ zombieJ merged commit 06de637 into ant-design:master Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants