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

Switching order problem in ReferenceManyField #5059

Closed
timofeyp opened this issue Jul 16, 2020 · 2 comments · Fixed by #5094
Closed

Switching order problem in ReferenceManyField #5059

timofeyp opened this issue Jul 16, 2020 · 2 comments · Fixed by #5094
Assignees
Labels

Comments

@timofeyp
Copy link

timofeyp commented Jul 16, 2020

What you were expecting:
I want to use sorting inside ReferenceManyField, as it works on List components: by clicking at column name, and then component switches its list order DESC\ASK.

What happened instead:
Just first click works. And there is order indicate icon just near first clicked column. No this icon on next clicked columns.

2020-07-16 18-56-42 2020-07-16 18_57_52

Steps to reproduce:
Just click at column names in app with ReferenceManyField component.

Related code:

`import React from 'react';
import PropTypes from 'prop-types';
import {
  Show,
  TextField,
  TabbedShowLayout,
  Tab,
  DateField,
  NumberField,
  ReferenceManyField,
  Datagrid,
  Pagination,
} from 'react-admin';
import SessionActions from 'components/Actions/SessionActions';

const View = (props) => (
  <Show
    actions={<SessionActions id={props.id} />}
    title={`Пользователь #${props.id}`}
    {...props}
  >
    <TabbedShowLayout>
      <Tab label="Инфо">
        <TextField label="Имя" source="first_name" />
        <TextField label="Отчество" source="middle_name" />
        <TextField label="Фамилия" source="last_name" />
        <NumberField label="Телефон" source="phone" />
      </Tab>
      <Tab label="Карты" path="body"></Tab>
      <Tab label="Девайсы" path="devices">
        <ReferenceManyField
          target="user_id"
          reference="devices"
          addLabel={false}
          pagination={<Pagination />}
        >
          <Datagrid>
            <TextField source="id" />
            <DateField source="created_at" />
            <DateField source="updated_at" />
            <TextField source="vendor_id" />
            <TextField source="push_token" />
          </Datagrid>
        </ReferenceManyField>
      </Tab>
      <Tab label="Сессии" path="sessions">
        <ReferenceManyField
          target="user_id"
          reference="sessions"
          addLabel={false}
          pagination={<Pagination />}
        >
          <Datagrid>
            <TextField source="id" />
            <DateField source="created_at" />
            <DateField source="updated_at" />
            <DateField source="expired_at" />
            <TextField source="useragent" />
          </Datagrid>
        </ReferenceManyField>
      </Tab>
    </TabbedShowLayout>
  </Show>
);

View.propTypes = {
  id: PropTypes.string,
};

export default View;
`

Other information:

Environment

  • React-admin version: "^3.7.1"
  • Last version that did not exhibit the issue (if applicable):
  • React version: "^16.13.1"
  • Browser: Chrome
  • Stack trace (in case of a JS error):
@Luwangel
Copy link
Contributor

Hi,

Thank you for opening this issue 🙏

I need to reproduce the problem you describe in order to fix it quickly.

As explained in the bug report template:

  1. Please fork the following template on CodeSandbox : React Admin Template
  2. Reproduce your bug. Remember to give us the clearest and simplest example possible.
  3. Reply to this issue with the link of your CodeSandbox, and extra information if it's necessary.

Regards,
Adrien

@timofeyp
Copy link
Author

timofeyp commented Jul 27, 2020

Hi,

Thank you for opening this issue 🙏

I need to reproduce the problem you describe in order to fix it quickly.

As explained in the bug report template:

  1. Please fork the following template on CodeSandbox : React Admin Template
  2. Reproduce your bug. Remember to give us the clearest and simplest example possible.
  3. Reply to this issue with the link of your CodeSandbox, and extra information if it's necessary.

Regards,
Adrien

So, bug is already in your template. Look at gif.

https://codesandbox.io/s/distracted-resonance-jwzuh

2020-07-27 19-57-08 2020-07-27 19_58_23

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.

2 participants