Skip to content

TypeError in dropdown-group when disconnected early #10028

@nwhittaker

Description

@nwhittaker

Check existing issues

Actual Behavior

If a <calcite-dropdown-group> is removed from the DOM before it's done loading, it can throw a TypeError: Cannot read properties of null (reading 'querySelectorAll').

Expected Behavior

It does not throw an error.

Reproduction Sample

https://codepen.io/nwhittaker-esri/pen/zYVdgqQ

Reproduction Steps

  1. Visit the repro and open the devtools console
  2. Click the Toggle dropdown group button and observe the TypeError log appears in the console

Reproduction Version

2.11.1

Relevant Info

Stack trace:

TypeError: Cannot read properties of null (reading 'querySelectorAll')
    at S.getGroupPosition (dropdown-group.tsx:166:29)
    at S.componentWillLoad (dropdown-group.tsx:85:31)
    at _e (index.js:1853:23)
    at ze (index.js:1649:22)
    at Array.r (index.js:1626:26)
    at M (index.js:185:13)
    at P (index.js:227:5)

I suspect treating this.el.parentElement here as optional would be sufficient:

this.el.parentElement.querySelectorAll("calcite-dropdown-group"),

Regression?

No response

Priority impact

impact - p2 - want for an upcoming milestone

Impact

The impact is largely with adding complexity to writing automated tests. In cases where the component is rendered as part of an acceptance test, its presence may not be important. However, the test still needs to wait for it to hydrate before performing an action that has the side-effect of removing the component.

Calcite package

  • @esri/calcite-components
  • @esri/calcite-components-angular
  • @esri/calcite-components-react
  • @esri/calcite-design-tokens
  • @esri/eslint-plugin-calcite-components

Esri team

ArcGIS Field Apps

Metadata

Metadata

Labels

4 - verifiedIssues that have been tested, confirmed as mitigated, and are ready to close.ArcGIS Field AppsIssues logged by ArcGIS Field Apps team members.bugBug reports for broken functionality. Issues should include a reproduction of the bug.calcite-componentsIssues specific to the @esri/calcite-components package.estimate - 3A day or two of work, likely requires updates to tests.impact - p2 - want for an upcoming milestoneUser set priority impact status of p2 - want for an upcoming milestonep - mediumIssue is non core or affecting less that 60% of people using the library

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions