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

[pickers] FocusTrap: Uncaught RangeError: Maximum call stack size exceeded #15069

Closed
efraimrodrigues opened this issue Oct 23, 2024 · 2 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information

Comments

@efraimrodrigues
Copy link

efraimrodrigues commented Oct 23, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/silly-pare-9hlp73

Steps:

  1. Open the browser console (for some reason the error doesn't show up in the CodeSandbox console)
  2. Click on the date picker icon
  3. Select any date
  4. Click on Simple Dialog
  5. Notice the Uncaught RangeError: Maximum call stack size exceeded. error in the console

Current behavior

After opening the DatePicker menu and another dialog on top of it, clicking anywhere inside the Dialog triggers a Maximum call stack size exceed error inside FocusTrap.

Expected behavior

The Uncaught RangeError: Maximum call stack size exceeded. error should not be thrown.

Context

In the real application we need to validate the selected dates and show a confirmation message inside a dialog on certain criteria, but clicking anywhere inside the Dialog throws an error and it closes the DatePicker selection menu (not sure if this is expected).

Your environment

npx @mui/envinfo
  System:
    OS: macOS 14.5
  Binaries:
    Node: 22.8.0 - ~/.nvm/versions/node/v22.8.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v22.8.0/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 130.0.6723.59
    Edge: Not Found
    Safari: 17.5
  npmPackages:
    @emotion/react: ^11.13.3 => 11.13.3 
    @emotion/styled: ^11.13.0 => 11.13.0 
    @mui/base:  5.0.0-beta.40 
    @mui/core-downloads-tracker:  5.16.7 
    @mui/icons-material: ^5.14.1 => 5.16.7 
    @mui/material: ^5.15.18 => 5.16.7 
    @mui/private-theming:  5.16.6 
    @mui/styled-engine:  5.16.6 
    @mui/system:  5.16.7 
    @mui/types:  7.2.16 
    @mui/utils:  5.16.6 
    @mui/x-data-grid: ^7.18.0 => 7.18.0 
    @mui/x-date-pickers: ^6.10.2 => 6.20.2 
    @mui/x-internals:  7.18.0 
    @types/react: ^18.0.37 => 18.3.5 
    react: ^18.2.0 => 18.3.1 
    react-dom: ^18.2.0 => 18.3.1 
    typescript: ^5.0.2 => 5.5.4

Search keywords: pickers,datepickers,focustrap

@efraimrodrigues efraimrodrigues added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 23, 2024
@github-actions github-actions bot added the component: pickers This is the name of the generic UI component, not the React module! label Oct 23, 2024
@arthurbalduini
Copy link
Member

arthurbalduini commented Oct 23, 2024

Hello @efraimrodrigues

I suspect the issue comes from the fact that both PickersPopper and Dialog (Modal) rely on the FocusTrap and the usage of them simultaneously might cause issues on the focus management.

I suggest you, as a workaround, to use the disableEnforceFocus prop in order to manage the focus changement among the components. Depending on what behavior you want to achieve, you might want to pass it to the DatePicker via slotProps:

<DatePicker
  onChange={handleChange}
  closeOnSelect={false}
  slotProps={{
    desktopTrapFocus: {
      disableEnforceFocus: true,
    },
  }}
/>

or to the Dialog:

<Dialog disableEnforceFocus open={open} onClose={handleClose}>

I tested both approaches and it seems to prevent the stack size error.
Let us know if this helps you 🙂

@arthurbalduini arthurbalduini changed the title FocusTrap: Uncaught RangeError: Maximum call stack size exceeded [pickers] FocusTrap: Uncaught RangeError: Maximum call stack size exceeded Oct 23, 2024
@arthurbalduini arthurbalduini added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer bug 🐛 Something doesn't work labels Oct 23, 2024
Copy link

The issue has been inactive for 7 days and has been automatically closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

2 participants