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

Filter with nested source does not work correctly #5361

Closed
wmwart opened this issue Oct 7, 2020 · 8 comments · Fixed by #5457
Closed

Filter with nested source does not work correctly #5361

wmwart opened this issue Oct 7, 2020 · 8 comments · Fixed by #5457
Assignees
Labels

Comments

@wmwart
Copy link

wmwart commented Oct 7, 2020

What you were expecting:
Expected intuitive filter operation, similar to filter operation without nested source

What happened instead:
Instead, when adding a filter to the screen, an extra request is made and the entries are pre-filtered unexpectedly

Steps to reproduce:

  1. Add a filter of the List view
const MyFilter = (props) => {
    return (
        <Filter {...props}>
            <TextInput source="controller.url" label="resources.Controller.fields.url"/>
        </Filter>
    )
};

const MyList = props => {
    return (
        <List {...props} filters={<MyFilter />}>
        ....
        </List>
    )
}

  1. Display the filter using the Add filter button
  2. Receive a request you did not expect.
    This behavior is not observed when using non-nested filters. For me, this behavior has become habitual and correct.

here's a link Codesandbox https://codesandbox.io/s/snowy-forest-2nnoy?file=/src/posts/PostList.js

  1. Add a filter comment.title to the Posts list view.
  2. Get unwanted filtering

Environment

  • React-admin version: 3.9.2
@fzaninotto
Copy link
Member

Receive a request you did not expect

Using your codesandbox, I added the comment.title to the posts list view, typed "lorem" in the input, and I saw the following data provider call:

getList posts {"pagination":{"page":1,"perPage":10},"sort":{"field":"published_at","order":"DESC"},"filter":{"comment":{"title":"lorem"}}}

This is what I expected.

What did you expect?

@wmwart
Copy link
Author

wmwart commented Oct 8, 2020

I expected that when adding a filter field to the screen (without entering any value), nothing happens to the current list. Instead, a request is sent to
getList posts {"pagination":{"page":1,"perPage":10},"sort":{"field":"published_at","order":"DESC"},"filter":{"comment":{}}}
and the list becomes empty.

This differs from the behavior of adding a filter for a non-nested field — until a filter value is entered, no pre-request is sent.
The difference in behavior for the user is not obvious.

Often the fields of nested filters are named as if it were a field of the current resource and it is difficult to explain to the user why it works differently.

Let me know if this behavior is expected for you.

@fzaninotto
Copy link
Member

You're right, it's a bug. Thanks for the report.

@wmwart
Copy link
Author

wmwart commented Nov 25, 2020

The problem is not solved.
Open codeandbox, update react-admin version to 3.9.6
Adding a nested filter to the screen still filters the list

@wmwart
Copy link
Author

wmwart commented Nov 25, 2020

Reopen a issue?

@djhi
Copy link
Collaborator

djhi commented Nov 25, 2020

Open codeandbox, update react-admin version to 3.9.6

Latest version is 3.10.2

@djhi
Copy link
Collaborator

djhi commented Nov 25, 2020

Sorry, probably related to #5559 ? Will be released in 3.10.3

@wmwart
Copy link
Author

wmwart commented Nov 26, 2020

no, you indicated that you fixed that in 3.9.6 https://github.com/marmelab/react-admin/releases/tag/v3.9.6

I was confused that when I updated the application a couple of weeks ago to 3.9.6 everything worked for me. I was delighted and removed some of the crutches in my backend. Everything worked in the release build. However, when yesterday they began to reassemble the release, the filters again stopped working correctly...
They searched for a long time and determined that if you slip a yarn.lock two weeks ago, then everything works.
Hence the conclusion - something has changed in your dependencies.

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

Successfully merging a pull request may close this issue.

3 participants