Navigation Menu

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

is there any new progess for this issue๏ผŸ

@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 November 14, 2019 11:01
@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
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

yoyo837
yoyo837 previously approved these changes Nov 15, 2019
Copy link
Contributor

@yoyo837 yoyo837 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 November 15, 2019 21:06
@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