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

In table column make filter-confirm possible when dropdown becomes hidden #31209

Open
1 task done
ifjGery opened this issue Jun 30, 2021 · 5 comments
Open
1 task done
Labels

Comments

@ifjGery
Copy link

ifjGery commented Jun 30, 2021

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

What problem does this feature solve?

It could make the end-user experience consistent.

If we have multiple columns in our table and we have mixed filters and filterDropdowns from column to column then the user experience is that there are some filers that don't need to be confirmed, only clicking away is enough and there are some that need to be.

What does the proposed API look like?

Two options come in mind:

1.

// FilterDropdown.tsx
const onVisibleChange = (newVisible: boolean) => {
[...]
  // add a new flag that will force confirmation on hide
  if (!newVisible && (!column.filterDropdown || column.confirmOnHide)) {
    onConfirm();
  }

now we can use it like this

<Table.Column
  filterDropdown={<CustomComponent />}
  confirmOnHide
/>

2.

// FilterDropdown.tsx
const triggerVisible = (newVisible: boolean) => {
  setVisible(newVisible);
  /* pass the confirmation function to
   * onFilterDropdownVisibleChange param, so user can call it when needed
   */
  onFilterDropdownVisibleChange?.(newVisible, onConfirm);
};

so we can use it like this

<Table.Column
  filterDropdown={<CustomComponent />}
  onFilterDropdownVisibleChange={(newVisible, confirm) => {
    if (!newVisible) {
      confirm();
    }
  }}
/>
@ifjGery
Copy link
Author

ifjGery commented Jun 30, 2021

I found the issue where the fix disabled the functionality for filterDropdown it was #17833 as mentioned in the 3.x-stable version. The suggestion in this issue was to expose an API to disable this behavior sound better to me than what we currently have, breaking the consistency without flags or switches to restore it.

@ifjGery
Copy link
Author

ifjGery commented Jun 30, 2021

I started working on this.

@afc163
Copy link
Member

afc163 commented Jul 2, 2021

I prefer your second proposal.

@ifjGery
Copy link
Author

ifjGery commented Jul 2, 2021

I actually went with a third option, please check the PR.

Nowhere in the documentation, it is mentioned that the filterdropDown is special and I did not found any indication in the code that it should be treated differently than the simpler filter. So by default, it should be triggering onConfirm and you will have to explicitly pass disableAutoConfirm to deviate from the default. On the other hand, both options 1 and 2 will be just a workaround to restore the intended default operation.

@ifjGery
Copy link
Author

ifjGery commented Sep 14, 2021

Could anyone check the PR related to this issue please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants