question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maximum call stack size exceeded when DatePicker inside a modal.

See original GitHub issue

Environment

Tech Version
material-ui-pickers 1.0.0-rc.10
material-ui 1.0.0-beta.47
React 16.3.2
Browser Chrome
Platform Elementary
Moment 2.22.2

Steps to reproduce

  1. Have a DatePicker inside of a Material-UI Dialog/Modal
  2. Click on datepicker

Expected behavior

DatePicker modal opens without errors being logged when clicked.

Actual behavior

The following errors are logger: Uncaught RangeError: Maximum call stack size exceeded. at HTMLDocument.Modal._this.enforceFocus (VM1034 Modal.js:185) at HTMLDocument.value (VM385 Modal.js:246) at HTMLDocument.Modal._this.enforceFocus (VM1034 Modal.js:185) at HTMLDocument.value (VM385 Modal.js:246) at HTMLDocument.Modal._this.enforceFocus (VM1034 Modal.js:185) at HTMLDocument.value (VM385 Modal.js:246) at HTMLDocument.Modal._this.enforceFocus (VM1034 Modal.js:185) …

Live example

Go here https://codesandbox.io/s/y2v3wz3lzx

I can work around this issue by passing disableEnforceFocus to <Dialog/>, but that is not ideal. Being able to pass Dialog/Modal options to the DatePicker would allow for a much better solution. That way a shared ModalManager or disableEnforceFocus could be passed to the Dialog.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Baradoycommented, Jun 20, 2018

Sorry, @kamalpy I have not had a chance to do anything with this yet. I set ‘disableEnforceFocus’ on the non-DatePicker modal for the moment. Hopefully in a week or two I can come back to this.

0reactions
zefjcommented, Oct 31, 2019

Closing in favor of #552

@cherniavskii how exactly does that solve the issue? The problem still exists while using inline datepicker inside of bootstrap modals - because bootstrap tries to trap focus inside the modal, while your library is trying to trap focus outside of it, in the popover portal.

Edit for future reference:

There’s an undocumented PopoverProps prop that you can use to sort of hack around this issue. The way I did this is I save a reference to the input field, and then check whether it’s rendered inside a bootstrap modal. If it is, then I supply the modal as container for the Popover portal. More or less like so:

const DatePickerComponent = (props) => {
    const ref = useRef();

    return (
        <DatePicker
            {...restDatePickerProps}

            TextFieldComponent={({ inputRef, ...restTextFieldProps }) => {
                ref.current = inputRef.current;
                return <input ref={inputRef} {...restTextFieldProps} />; // this is just for the sake of keeping the example syntax semi-correct, will probably warn the shit out of your console
            }}
            
            PopoverProps={{
                container: () => {
                    const bootstrapModal = document.querySelector('div.modal.show'); // Make sure the selector is specific enough for your use-case

                    if (bootstrapModal && bootstrapModal.contains(ref.current)) {
                        return bootstrapModal;
                    }

                    return null; // Let the popover fallback to it's default behaviour
                },
            }}
        />
    );
}

This obviously has it’s drawbacks, like the fact you have to override TextFieldComponent, but we do that anyway so it works for our usecase.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maximum call stack size exceeded when DatePicker inside a ...
I can work around this issue by passing disableEnforceFocus to <Dialog/>, but that is not ideal. Being able to pass Dialog/Modal options to...
Read more >
Uncaught RangeError: Maximum call stack size exceeded
After clicking on the select, i'm getting this error from Modal.js: "Uncaught RangeError: Maximum call stack size exceeded. at HTMLDocument.
Read more >
date picker in mdb modal - Material Design for Bootstrap
Expected behavior work Actual behavior gives error Modal.js?a179:227 Uncaught RangeError: Maximum call stack size exceeded. Resources (screenshots, code ...
Read more >
RangeError: Maximum call stack size exceeded - Educative.io
In this shot, we will see how to fix the “RangeError: Maximum call stack size exceeded” error. ... The most common source for...
Read more >
A brand new website interface for an even better experience!
Maximum call stack size exceeded when DatePicker inside a modal.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found