ant-design/ant-design

table filterIcon click the first second times will call onChange,but just the first second times ,the second second ....times will not #11164

FightingJane posted onGitHub

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.6.4

Environment

win7 google 版本 63.0.3239.132(正式版本)

Edit on CodeSandbox

Steps to reproduce

click the filterIcon,show filterDropdown, click the filterIcon again ,will alert('test')

What is expected?

not call onChange

What is actually happening?

call onChange


how to prevent from calling onChange?

filterDropDown.js the judge seem to be a bit of a problem:

{
        key: 'confirmFilter',
        value: function confirmFilter() {
            if (this.state.selectedKeys !== this.props.selectedKeys) {
                this.props.confirmFilter(this.props.column, this.state.selectedKeys);
            }
        }

<!-- generated by ant-design-issue-helper. DO NOT REMOVE -->


I've experienced the same bug and I fixed it and created pull request https://github.com/ant-design/ant-design/pull/11166

posted by adybionka almost 7 years ago

Some background: this bug was introduced with bug fix for these issues: https://github.com/ant-design/ant-design/issues/10289 and https://github.com/ant-design/ant-design/issues/10209.

This is fix for this bug:

        if ('selectedKeys' in nextProps && !shallowequal(this.props.selectedKeys, nextProps.selectedKeys)) {
            newState.selectedKeys = nextProps.selectedKeys;
        }

as we can see selectedKeys is updated in the state only when this.props.selectedKeys and nextProps.selectedKeys has different content. In case when both are empty objects but are not the same objects a confirmFilter prop function will be fired according to this condition: if (this.state.selectedKeys !== this.props.selectedKeys).

posted by adybionka almost 7 years ago

@adybionka Oh, I see. 3Q

posted by FightingJane almost 7 years ago

@0maxxam0 funded this issue with $5. Visit this issue on Issuehunt

posted by IssueHuntBot almost 7 years ago

@loadbalance-sudachi-kun funded this issue with $256. Visit this issue on Issuehunt

posted by IssueHuntBot over 6 years ago

@afc163 has cancelled @0maxxam0's funding for this issue.(Cancelled amount: $5.00) See it on IssueHunt

posted by issuehunt-app[bot] about 5 years ago

@afc163 has cancelled @loadbalance-sudachi-kun's funding for this issue.(Cancelled amount: $256.00) See it on IssueHunt

posted by issuehunt-app[bot] about 5 years ago

Fund this Issue

$0.00
Funded

Pull requests

Recent activities

afc163 cancelled funding 256.00 for  ant-design/ ant-design#11164
about 5 years ago
afc163 cancelled funding 5.00 for  ant-design/ ant-design#11164
about 5 years ago