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

Lost filters after edit resource #4835

Closed
hugofialho opened this issue May 20, 2020 · 4 comments · Fixed by #4868
Closed

Lost filters after edit resource #4835

hugofialho opened this issue May 20, 2020 · 4 comments · Fixed by #4868
Assignees
Labels

Comments

@hugofialho
Copy link

What you were expecting:
Afeter edit resource redirect to list with filters.

What happened instead:
Redirect to list without filters.

Steps to reproduce:
Access demo(https://marmelab.com/react-admin-demo/#/).
Go to Catalog/Categories.
Click on Products inside any category.
Edit any poster.
You lost Category filter.

Related code:
It happens on demo(https://marmelab.com/react-admin-demo/#/categories)

@fzaninotto fzaninotto added the bug label May 21, 2020
@fzaninotto
Copy link
Member

Thanks for the report, I reproduced the bug.

This only happens with the category link. Setting the Category filter manually in the Product list makes it persistent.

@fzaninotto
Copy link
Member

The problem comes from useListParams: it doesn't dispatch a changeListParams on mount if the params from the state differ from the params from the location (which would imply a direct link to a filtered list).

@argestes
Copy link

I'm having somewhat related issue. I have this button inside a list which fetches a resource. After fetch succeds for a split second the updated resource is shown on the list but after that query changes and i'm redirected to first page of 'books'. Even if i remove refresh it's still the same issue. I need the grid to stay the same after this call.

export const FetchButton = ({record, ...rest}) => {
    const notify = useNotify();
    const refresh = useRefresh();
    const dataProvider = useDataProvider();
    const fetch = () => dataProvider
        .update('books', {
            id: record.id + "/fetch", data: {request_fetch: true}
        })
        .then(response => {
            refresh()
            notify(`Book fetched`, 'info', {}, false);
        }).catch(error => {
                notify(`Book fetch failed`, "warning");
            }
        );

    return record && !record["name"] ?
        <Button label="Fetch" onClick={fetch}/> :
        null;
}

export const BookList = (props) => (
    <List {...props}>
        <Datagrid>
            <TextField source="id"/>
            <TextField source="name"/>
            <TextField source="isbn"/>
            <FetchButton/>
            <EditButton/>
        </Datagrid>
    </List>
);```

@fzaninotto
Copy link
Member

@argestes This is probably not the same problem. I suggest you ask for troubleshoot help in StackOverflow.

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.

4 participants