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: undefined in filterDropdown in Table should not render dropdown … #27002

Merged

Conversation

shangyilim
Copy link
Contributor

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

  1. Column renders a filter button if filterDropdown is set to undefined #26988

💡 Background and solution

When creating a Table with some columns, when the column filterDropdown is set to undefined, the dropdown is rendered with no content. See example
image

Although it makes sense to just not include filterDropdown to the column if no filter is needed, creating dynamic columns can be a challenge, and make code harder to read:

if (condition) {
  return {
      title: "Name",
      dataIndex: "name",
      filterDropdown: CustomDropdownComponnt
  };
} else {
  return {
      title: "Name",
      dataIndex: "name",
  };
}

compared to

return {
    title: "Name",
    dataIndex: "name",
    filterDropdown: condition ? CustomDropdownComponent : undefined
};

The fix made is by checking to make sure that if dropdownFilteris specified it must be truthy before rendering the dropdown.

📝 Changelog

Language Changelog
🇺🇸 English Table filter dropdown icon no longer appears if filterDropdown in column is set undefined or `null
🇨🇳 Chinese

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • 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 Oct 3, 2020

@ant-design-bot
Copy link
Contributor

ant-design-bot commented Oct 3, 2020

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 3, 2020

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 014c236:

Sandbox Source
antd reproduction template Configuration
vibrant-cdn-siftn PR

@codecov
Copy link

codecov bot commented Oct 3, 2020

Codecov Report

Merging #27002 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master    #27002   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          384       384           
  Lines         7369      7369           
  Branches      2009      2058   +49     
=========================================
  Hits          7369      7369           
Impacted Files Coverage Δ
components/table/hooks/useFilter/index.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f07613a...014c236. Read the comment docs.

@afc163 afc163 merged commit fa3c00c into ant-design:master Oct 4, 2020
@afc163 afc163 mentioned this pull request Oct 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.

3 participants