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

"TypeError: Cannot read property 'contains' of null" after update to latest version #2741

Open
simeongr opened this issue May 3, 2023 · 1 comment

Comments

@simeongr
Copy link

simeongr commented May 3, 2023

  • components: Dropdown
  • reactstrap version #9.1.9
  • import method es
  • react version #18.0.26
  • bootstrap version #5.2.3

What is happening?

I have only updated reactstrap from v9.1.5 to v9.1.9 and unit tests are failing.

What should be happening?

No failed unit tests.

Steps to reproduce issue

npm update reactstrap
npm run test ./...

Error message in console

   TypeError: Cannot read property 'contains' of null

      278 |
      279 |       fireEvent.change(contactChangeInput, { target: { value: 'valid-email@test.com' } });
    > 280 |       fireEvent.click(cancelButton);
          |                 ^

at Dropdown.handleDocumentClick (node_modules/reactstrap/lib/Dropdown.js:86:35)
at Document.callTheUserObjectsOperation (node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)
at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:338:25)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3)
at HTMLButtonElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:205:9)
at HTMLButtonElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:94:17)
at HTMLButtonElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:231:34)
at node_modules/@testing-library/dom/dist/events.js:19:20
at node_modules/@testing-library/react/dist/pure.js:79:16
at node_modules/@testing-library/react/dist/act-compat.js:64:24
at act (node_modules/react/cjs/react.development.js:2512:16)
at node_modules/@testing-library/react/dist/act-compat.js:63:25
at Object.eventWrapper (node_modules/@testing-library/react/dist/pure.js:78:28)
at fireEvent (node_modules/@testing-library/dom/dist/events.js:12:35)
at Function.fireEvent.<computed> [as click] (node_modules/@testing-library/dom/dist/events.js:110:36)
at Function.click (node_modules/@testing-library/react/dist/fire-event.js:18:52)
@whatbird
Copy link

whatbird commented May 16, 2023

seeing something similar to this coming from our production exception tracker. reported like so:

Message: Cannot read properties of null (reading 'contains')
at contains line 114, column 34 (../node_modules/reactstrap/esm/Dropdown.js:114)
            
    var container = this.getContainer();
    var menu = this.getMenu();
    var toggle = this.getToggle();
    var targetIsToggle = toggle.contains(e.target);
    var clickIsInMenu = menu && menu.contains(e.target) && menu !== e.target;
    var clickIsInInput = false;
    if (container) {

update: perhaps introduced here? fa1fcc8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants