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

[BUG] - setFilters with filters.mode="off" not updating the table #4378

Closed
Abenezer opened this issue May 23, 2023 · 11 comments
Closed

[BUG] - setFilters with filters.mode="off" not updating the table #4378

Abenezer opened this issue May 23, 2023 · 11 comments
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest wontfix This will not be worked on

Comments

@Abenezer
Copy link

Describe the bug

when using external search box to filter a table with filter.mode set to "off" the filter query is correctly displayed on the location bar but the table will not be updated until the page is refreshed. i forked the basic example of react-table with charka-ui and able to reproduce the issue.

Steps To Reproduce

open https://codesandbox.io/p/sandbox/solitary-architecture-fne4uq?file=%2Fsrc%2Fpages%2Fposts%2Flist.tsx%3A140%2C21
on the text filed "search by title" type any of the title eg. rter
the table is not filtered. even though the query string on location bar is set correctly

but if filters.mode is set to server or cleared the table will be filtered as expected.

Expected behavior

the table should be updated when user types text on the search field without requesting the server if filter.mode is set to "off".
(only works after refreshing the page)

Screenshot

No response

Desktop

No response

Mobile

No response

Additional Context

No response

@Abenezer Abenezer added the bug Something isn't working label May 23, 2023
@BatuhanW
Copy link
Member

Hello @Abenezer, thanks for the detailed report! We'll check and get back to you.

@alicanerdurmaz
Copy link
Member

Hi @Abenezer, This does not work because when filters.mode="off" you need to handle filters on the client side with the help of TanStack Table.

you can use it like this:
https://codesandbox.io/p/sandbox/boring-water-ubs5wo?file=%2Fsrc%2Fpages%2Fposts%2Flist.tsx%3A174%2C1-175%2C1

other filters work as expected (dropdown, sorters, etc.) because we already write the required logic on /components/table/columnFilter.tsx

@Abenezer
Copy link
Author

thankyou for the fast response. one thing i did not understand is how it was able to work when refreshing the page if the logic is not implemented. I can work like the example you provided, setting column filter like this might be even better. thankyou.

@alicanerdurmaz
Copy link
Member

alicanerdurmaz commented May 24, 2023

@Abenezer After refresh works because we are populating TanStack Table's initialState with URL params.

@omeraplak omeraplak reopened this May 24, 2023
@alicanerdurmaz
Copy link
Member

@Abenezer We discuss this issue with the core team and decided this behavior and implementation are quite confusing. Next week we will plan this feature and we will improve the API and documentation of useTable to make it more understandable.

Thanks for the issue 🚀

@alicanerdurmaz
Copy link
Member

@Abenezer Hi again, due to our higher priority tasks this week, we couldn't schedule this job. We hope to schedule and complete it next week ✌️.

@stale
Copy link

stale bot commented Aug 11, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Aug 11, 2023
@stale stale bot closed this as completed Aug 18, 2023
@omeraplak omeraplak reopened this Aug 18, 2023
@stale stale bot removed the wontfix This will not be worked on label Aug 18, 2023
@omeraplak omeraplak added the good first issue Good for newcomers label Nov 21, 2023
Copy link

stale bot commented Jan 20, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jan 20, 2024
@BatuhanW BatuhanW added hacktoberfest and removed wontfix This will not be worked on labels Jan 22, 2024
@jaychang99
Copy link

jaychang99 commented Feb 3, 2024

I have the same issue, except that the table data won't be filtered even after full reload (refresh). I am using ant-design as my UI library.

'use client';
import {
  useTable,
  List,
  EditButton,
  ShowButton,
  DeleteButton,
} from '@refinedev/antd';
import { Table, Space, Input } from 'antd';

import { IPost } from 'src/interfaces';

const WordList: React.FC = () => {
  const { tableProps, setFilters, filters } = useTable<IPost>({
    resource: 'words',
    pagination: {
      mode: 'client',
      pageSize: 20,
    },
    filters: {
      mode: 'off',
    },
  });

  return (
    <List>
      {/* search form */}
      <Input.Search
        onChange={(event) => {
          console.log('value', event.target.value);
          setFilters([
            {
              field: 'firstChar',
              operator: 'eq',
              value: String(event.target.value),
            },
          ]);
        }}
      />
      <Table {...tableProps} rowKey="id" size="small">
        <Table.Column dataIndex="id" title="ID" />
        <Table.Column dataIndex="word" title="Word" />
        <Table.Column dataIndex="length" title="Length" />
        <Table.Column<IPost>
          title="Actions"
          dataIndex="actions"
          render={(_text, record): React.ReactNode => {
            return (
              <Space>
                <EditButton size="small" recordItemId={record.id} />
                <ShowButton size="small" recordItemId={record.id} />
                <DeleteButton size="small" recordItemId={record.id} />
              </Space>
            );
          }}
        />
      </Table>
    </List>
  );
};

export default WordList;

Copy link

stale bot commented Apr 4, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Apr 4, 2024
@stale stale bot closed this as completed Apr 11, 2024
@reedwane
Copy link

I am also facing this issue too. I'm passing the needed filters as arguments to a custom queryFn, and also declared my custom queryKeys and added an object with the filters to force trigger a refetch with the passed filters. But this isn't working at all

I thought I read it all correctly from the useTable docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

7 participants