reactstrap
reactstrap copied to clipboard
"TypeError: Cannot read property 'contains' of null" after update to latest version
- 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: '[email protected]' } });
> 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)
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? https://github.com/reactstrap/reactstrap/commit/fa1fcc84511582f5e22d42c73c2ff1bb8c805f9b