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

[DataGrid] Filter text input does not work if is inside a Dialog #2230

Closed
2 tasks done
incompl opened this issue Jul 28, 2021 · 7 comments
Closed
2 tasks done

[DataGrid] Filter text input does not work if is inside a Dialog #2230

incompl opened this issue Jul 28, 2021 · 7 comments
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! MUI Core v4.x

Comments

@incompl
Copy link

incompl commented Jul 28, 2021

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

When a DataGrid is in a Dialog and you try to add a filter, the text input for the filter doesn't get a cursor when you click on it as if it's disabled. (I don't believe it's really disabled since it has the hover behavior of being enabled)

Expected Behavior 🤔

Filtering should work normally if a Dialog

Steps to Reproduce 🕹

https://codesandbox.io/s/datagrid-in-dialog-filter-bug-ix616

Steps:

  1. Open the code sandbox
  2. Click the kebab icon next to "Name" to open the column menu
  3. Click "Filter"
  4. Click "Filter value"
  5. Note you cannot input text

Context 🔦

We have a home grown version of this library that we would like to replace with DataGrid and I found this issue while evaluating it. We use tables in Dialogs for operations like data imports where you select rows to import.

Your Environment 🌎

Codesandbox.io and Chrome 92.0.4515.107

Order id 💳

I am an open source user 🥳

@incompl incompl added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 28, 2021
@DanailH
Copy link
Member

DanailH commented Jul 29, 2021

Hi @incompl maybe I'm missing something but I wasn't able to reproduce the issue using the example you provided, maybe the codesandbox link is not up to date?

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 29, 2021

@incompl
Copy link
Author

incompl commented Jul 29, 2021

@DanailH Sorry about that, I guess my sandbox didn't save somehow. I reopened it and it had my fix, then I refreshed and it was gone. In any case, the sandbox that @oliviertassinari provided is the same thing that mine contained.

[edit] I believe mine is properly updated now.

@flaviendelangle
Copy link
Member

flaviendelangle commented Jul 30, 2021

By default I seems that the Dialog component forces the focus to stay inside it.
Adding the disableEnforceFocus to it fixes you issue.
I don't know if there is a smarter way of doing it inside the Grid.

https://codesandbox.io/s/datagrid-in-dialog-filter-bug-forked-plub7

@m4theushw
Copy link
Member

m4theushw commented Jul 30, 2021

This is actually a bug in the TrapFocus of the MUI v4. Opening a Popper (e.g. the filter panel) inside a dialog doesn't work: mui/material-ui#15694

There are 3 options to solve your problem:

  1. Update Material UI to v5 as support for Portal in TrapFocus is fixed in this version

  2. Add disableEnforceFocus to the Dialog

  3. Disable the Portal in the filter panel:

<DataGrid componentsProps={{ panel: { disablePortal: true } }} />

Using this option, you have to update your CSS to disable the box-sizing: border-box applied to the text fields.

@m4theushw m4theushw added external dependency Blocked by external dependency, we can’t do anything about it and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 30, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 31, 2021

Closing per 1. it's already fixed in Material UI v5. It's about portal support in TrapFocus.

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! MUI Core v4.x and removed external dependency Blocked by external dependency, we can’t do anything about it labels Jul 31, 2021
@oliviertassinari oliviertassinari changed the title Filter text input does not work if DataGrid is inside a Dialog [DataGrid] Filter text input does not work if is inside a Dialog Jul 31, 2021
@leebask
Copy link

leebask commented Nov 27, 2024

This is actually a bug in the TrapFocus of the MUI v4. Opening a Popper (e.g. the filter panel) inside a dialog doesn't work: mui/material-ui#15694

There are 3 options to solve your problem:

  1. Update MUI to v5 as support for Portal in TrapFocus is fixed in this version
  2. Add disableEnforceFocus to the Dialog
  3. Disable the Portal in the filter panel:
<DataGrid componentsProps={{ panel: { disablePortal: true } }} />

Using this option, you have to update your CSS to disable the box-sizing: border-box applied to the text fields.

I think option 2 is the best choose, i was try , fixed , MUI v5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! MUI Core v4.x
Projects
None yet
Development

No branches or pull requests

6 participants