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.

error after upgrading react-bootstrap - CustomModalDialog is out of date

See original GitHub issue

After one of the latest versions update, with react-bootstrap update, maybe #3249, my environment is with the latest react and react-dom and my tests started to fail with the following error:

console.error node_modules/jest-prop-type-error/index.js:8
    onMouseDownDialog 
        in div (created by CustomModalDialog)
        in CustomModalDialog (created by Modal)
        in Transition (created by Fade)
        in Fade (created by DialogTransition)
        in DialogTransition (created by Modal)
        in RefHolder (created by Modal)
        in div (created by Modal)
        in Portal (created by Modal)
        in Modal (created by Modal)
        in Modal (created by DiffModal)

and the warning: Warning: Unknown event handler property %s. It will be ignored.%s maybe it is something about a naming convention, see: https://github.com/styled-components/styled-components/issues/2218#issuecomment-489661463

opened an issue to react-bootstrap - https://github.com/react-bootstrap/react-bootstrap/issues/4872

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
mturleycommented, Dec 13, 2019

Ok, I think I figured out what’s going on here. This is the version of the error I’m seeing in v2v:

Warning: Unknown event handler property `onMouseDownDialog`. It will be ignored.
    in div (created by CustomModalDialog)
    in CustomModalDialog (created by Modal)
    in Transition (created by Fade)
    in Fade (created by DialogTransition)
    in DialogTransition (created by Modal)
    in RefHolder (created by Modal)
    in div (created by Modal)
    in Portal (created by Modal)
    in Modal (created by Modal)
[truncated]

It looks like the problem is that an onMouseDownDialog prop is being applied to a plain <div> element, causing a warning since this is not a valid prop for a <div>. I can only find one place in react-bootstrap@0.33.0 where this prop is passed, and it appears to be coming from this line: https://github.com/react-bootstrap/react-bootstrap/blob/bs3-dev/src/Modal.js#L287

That <Dialog> the prop is being passed to there is actually defined by the dialogComponentClass prop here, which defaults to ModalDialog here. If passed to ModalDialog as is the default behavior, it’s handled correctly and won’t be applied to a <div>.

So this means that somewhere, a <Modal> is being rendered with dialogComponentClass set to either a div or something that passes all its props to a div. I can’t find anywhere in the react-bootstrap code where that is happening, so I started thinking it might be our usage in patternfly-react.

Searching patternfly-react for dialogComponentClass reveals that we pass our own CustomModalDialog into this prop in our wrapper for react-bootstrap’s Modal: https://github.com/patternfly/patternfly-react/blob/master/packages/patternfly-3/patternfly-react/src/components/Modal/Modal.js#L23. It turns out, we made a copy of the original r-bs ModalDialog as our own CustomModalDialog with some tweaks.

So, the bug is happening because CustomModalDialog ends up including the unexpected onMouseDownDialog prop in its elementProps object, which it then spreads directly onto the <div> here.

To fix this, we simply need to update our CustomModalDialog to replicate this change react-bootstrap made to their original ModalDialog: https://github.com/react-bootstrap/react-bootstrap/commit/87a9a97f8670f3a02436f8f520caf36f88e4bdab#diff-e62f630dfbeeba1084a3724f9d4dbf98 and pull the onMouseDownDialog prop out and apply it to the div as onMouseDown.

While we’re at it, we should probably just update that whole file to match the new react-bootstrap version in case anything else changed, and preserve whatever it was that we modified to be custom. Maybe we can even just stop using that custom component. We should look for others like it that we copy-pasted… we may have caused other issues by essentially upgrading react-bootstrap while overriding bits of it with its old code.

3reactions
rachael-phillipscommented, Dec 2, 2019

Hi @laviro our team has seen this, and we will be taking a look at it this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Bootstrap modal not closing. Error: Cannot update a ...
What this does is: on each render of PersonalDetails , this will just set the state for the show state back in OnboardPage...
Read more >
react-bootstrap's Modal does not work with React 16 #2812
When I upgraded to React 16, everything in my app worked as normal except for react-bootstrap Modals. I'm seeing the same context.contains error...
Read more >
Working with Bootstrap's Modals in React | Pluralsight
In this guide I will show you how to install react-bootstrap, show and hide a modal, work with different modal events, and customize...
Read more >
<Modal/> Component - React-Bootstrap
Modals are unmounted when closed. Bootstrap only supports one modal window at a time. Nested modals aren't supported, but if you really need...
Read more >
Get started with Bootstrap · Bootstrap v5.2
Get started by including Bootstrap's production-ready CSS and JavaScript via CDN ... Stay up-to-date on the development of Bootstrap and reach out to...
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