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

Max call stack - Modal._this.enforceFocus #10341

Closed
1 task done
samdenty opened this issue Feb 19, 2018 · 10 comments
Closed
1 task done

Max call stack - Modal._this.enforceFocus #10341

samdenty opened this issue Feb 19, 2018 · 10 comments
Labels
component: modal This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement

Comments

@samdenty
Copy link
Contributor

samdenty commented Feb 19, 2018

image
image

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Doesn't exceed the call stack

Current Behavior

Maximum call stack size exceeded

Steps to Reproduce (for bugs)

I can't fully reproduce this issue, as it seems it's an edge case - but this was the environment in which it occurred

  1. Add a component to the page which keeps itself in focus (monaco editor in this case)
  2. Open up a new modal
  3. Max call stack exceeded

Your Environment

Tech Version
Material-UI beta.34
React 16.2.0
@oliviertassinari
Copy link
Member

oliviertassinari commented Feb 19, 2018

Add a component to the page which keeps itself in focus

@samdenty99 The modal also keeps itself in focus. The maximum call stack error is the expected behavior. You have an infinite focus loop.
Ideally, the modal component should be able to detect the loop and raised an extra warning along suggesting people to diable the behavior with disableEnforceFocus.

Given it's the first time the problem is raised. Let's use this issue as documentation for future people facing it.

@mui mui deleted a comment from alphaeadevelopment Feb 27, 2018
@mui mui deleted a comment from marcoturi Feb 27, 2018
@oliviertassinari oliviertassinari added component: modal This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement labels Feb 27, 2018
@albinekb
Copy link
Contributor

albinekb commented May 3, 2018

I got this error when using a Popover inside my Dialog with focus on an Input, i found this issue by google and solved it by adding disableEnforceFocus when the input was focused and the Popover is visible, I think this issue is enough 👍

@nbkhope
Copy link

nbkhope commented Aug 13, 2018

Got the same problem as @albinekb with a Popover (Select) inside a Modal. Why is this error normal behavior?

@EsaNuurtamo
Copy link

I get this error when I open Dialog from Menu-component. If I open my Dialog by clicking Button I don't get the error.

@Alexandr-Ilyin
Copy link

Also facing the issue when opening dialog from menu

@oakis
Copy link

oakis commented Nov 6, 2018

disableEnforceFocus inside Dialog solved this issue for me.

@aaadryyy
Copy link

aaadryyy commented Jan 27, 2021

O thou traveler for whom disableEnforceFocus doesn't work, thou may try using disablePortal on thou Modal's Popover.

@jameswlale
Copy link

O thou traveler for whom disableEnforceFocus doesn't work, thou may try using disablePortal on thou Modal's Popover.

cheers @aaadryyy using disablePortal on the select component worked a treat.

In my case, i was receiving that error when focusing a select component inside a focus trapped form, not using a dialog component as a container, instead a straight forward portal.

<Select ...{} MenuProps={{ disablePortal: true }} />

@MPragya-20
Copy link

disableEnforceFocus worked...thanksss

@kauffmanes
Copy link

disableEnforceFocus also works for me, but I'm concerned about using it...doesn't it cause accessibility issues with a screen reader? I'm assuming if this is happening, and someone using a SR is on the page, then it's going to jump back and forth between the select and the dialog. I'm thinking @jameswlale has the right idea - disable the select so it can't jump to focus there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: modal This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests