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

feat(table): Add defaultFilteredValues to table columns #18925

Merged
merged 1 commit into from Nov 16, 2019

Conversation

mgcrea
Copy link
Contributor

@mgcrea mgcrea commented Sep 20, 2019

🤔 This is a ...

  • New feature

🔗 Related issue link

We have the ability to se a defaultSortOrder to a <Table /> column. Being able to set a defaultFilteredValue seems to be missing and would be great to easily set defaults without having to maintain a state.

In my case, I'm restoring sorters/filters from localStorage.

💡 Background and solution

Basically cloned the existing codepath for defaultSortOrder to have minimal impact.

📝 Changelog

Language Changelog
🇺🇸 English Ability to use defaultFilteredValue as a new column prop to set a default filter
🇨🇳 Chinese 允许使用 defaultFilteredValue 作为列的默认筛选值

PR is missing Chinese translation too as I'm not fluent unfortunately :).

☑️ 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

View rendered components/table/demo/head.md
View rendered components/table/index.en-US.md
View rendered components/table/index.zh-CN.md

@todo
Copy link

todo bot commented Sep 20, 2019

| string[] | - | |

https://github.com/ant-design/ant-design/blob/3706aa6b0a1a8332de1715a1e9e339c7763d1c8e/components/table/index.zh-CN.md#L132-L135


This comment was generated by todo based on a TODO comment in 3706aa6b0a1a8332de1715a1e9e339c7763d1c8e in #18925. cc @mgcrea.

Copy link

@tests-checker tests-checker bot left a comment

Could you please add tests to make sure this change works as expected?

@netlify
Copy link

netlify bot commented Sep 20, 2019

Deploy preview for ant-design ready!

Built with commit ecae5dc

https://deploy-preview-18925--ant-design.netlify.com

@codecov
Copy link

codecov bot commented Sep 20, 2019

Codecov Report

No coverage uploaded for pull request base (feature@8f52b80). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##             feature   #18925   +/-   ##
==========================================
  Coverage           ?   97.81%           
==========================================
  Files              ?      286           
  Lines              ?     7722           
  Branches           ?     2126           
==========================================
  Hits               ?     7553           
  Misses             ?      169           
  Partials           ?        0
Impacted Files Coverage Δ
components/table/Table.tsx 99.49% <100%> (ø)

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 8f52b80...ecae5dc. Read the comment docs.

@mgcrea
Copy link
Contributor Author

mgcrea commented Oct 31, 2019

@afc163 Looks like this PR is in limbo, it only lacks chinese translations, any chance to have it reviewed? Thanks!

@henrycjchen
Copy link

henrycjchen commented Nov 12, 2019

is there any new progess for this issue?

components/table/index.zh-CN.md Outdated Show resolved Hide resolved
@mgcrea mgcrea force-pushed the feat-defaultFilteredValues branch from 19358d4 to 055d619 Compare Nov 14, 2019
@buildsize
Copy link

buildsize bot commented Nov 14, 2019

File name Previous Size New Size Change
package-lock.json 955.94 KB 960.86 KB 4.92 KB (1%)

@mgcrea mgcrea requested a review from yoyo837 Nov 14, 2019
@yoyo837 yoyo837 changed the title Add defaultFilteredValues to table columns feat(table): Add defaultFilteredValues to table columns Nov 14, 2019
@yoyo837
Copy link
Contributor

yoyo837 commented Nov 14, 2019

How does it work well with filteredValue?

@mgcrea mgcrea force-pushed the feat-defaultFilteredValues branch from 055d619 to 081a3cf Compare Nov 14, 2019
@mgcrea
Copy link
Contributor Author

mgcrea commented Nov 14, 2019

How does it work well with filteredValue?

@yoyo837 It is properly overidden by filteredValue, exactly like sortOrder overrides defaultSortOrder.

I've updated the tests to better reflect this components/table/tests/Table.filter.test.js

@mgcrea mgcrea force-pushed the feat-defaultFilteredValues branch from 081a3cf to effa545 Compare Nov 14, 2019
yoyo837
yoyo837 previously approved these changes Nov 15, 2019
Copy link
Contributor

@yoyo837 yoyo837 left a comment

LGTM

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 15, 2019

Please add another case test:
filterValue:['Tom'] override defaultFilteredValue:['Lucy'].

@mgcrea
Copy link
Contributor Author

mgcrea commented Nov 15, 2019

Please add another case test:
filterValue:['Tom'] override defaultFilteredValue:['Lucy'].

@yoyo837 done

@mgcrea mgcrea requested a review from yoyo837 Nov 15, 2019
@yoyo837 yoyo837 merged commit 103920e into ant-design:feature Nov 16, 2019
26 checks passed
@zombieJ
Copy link
Member

zombieJ commented Dec 1, 2019

@mgcrea, could you help to add this feature in 4.0-prepare branch also?

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

4 participants