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

conditionally visible column disappears from DatagridConfigurable and column visibility switcher is bugged #8927

Closed
dkocich opened this issue May 19, 2023 · 3 comments · Fixed by #8929
Assignees
Labels

Comments

@dkocich
Copy link

dkocich commented May 19, 2023

What you were expecting:

the column is shown, visibility switched should work changing the visibility of a correct column. Typescript error might appear that the DatagridConfigurable does not expect null as children. This is hard to spot that we miss one column there in the app with 80 lists.

What happened instead:

I used the condition to show one column only in dev mode, and it happened that on PROD the first column was missing from the list

          <DatagridConfigurable bulkActionButtons={false}>
            {isLocalhost() && (
              <TextField
                emptyText={NUL}
                label="id"
                sortable={isVehiclePropSortable("id")}
                source="id"
              />
            )}

and the column switcher was not switching the visibility of the correct columns, it switched some other columns

Screenshot 2023-05-19 at 12 39 01

Probably the solution is to use {isLocalhost() ? ... : <Fragment/> instead - then the first column of a table is visible again and the visibility switcher works. (but switcher shows "hidden" column as "unlabelled column" which does nothing)

...

Steps to reproduce:

Related code:
https://stackblitz.com/edit/github-tpakk4?file=src%2Fposts%2FPostList.tsx,src%2Findex.tsx,src%2Fposts%2Findex.tsx

  • in PostList.tsx you can see the first column as conditionally hidden, it does not appear on the page - then switching the visibility of any column hides a different one

Other information:

Environment

  • React-admin version:
  • "react-admin": "4.8.4",
    
  • Last version that did not exhibit the issue (if applicable): not sure
  • React version:
  • "react": "18.2.0",
    
  • Browser: chrome
  • Stack trace (in case of a JS error):
@fzaninotto
Copy link
Member

Please provide a way to reproduce the error

@dkocich
Copy link
Author

dkocich commented May 19, 2023

@fzaninotto
https://stackblitz.com/edit/github-tpakk4?file=src%2Fposts%2FPostList.tsx,src%2Findex.tsx,src%2Fposts%2Findex.tsx

  • in PostList.tsx you can see the first column as conditionally hidden, it does not appear on the page - then switching the visibility of any column hides a different one
    Screenshot 2023-05-19 at 15 36 12

@fzaninotto
Copy link
Member

Reproduced, thanks.

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