[Bug]: Menu component does not protect access to refs in focusItem #16395
Labels
good first issue 👋
Used by GitHub to elevate contribution opportunities
needs: community contribution
Due to roadmap and resource availability, we are looking for outside contributions on this issue.
severity: 2
User cannot complete task, and/or no workaround
status: help wanted 👐
type: bug 🐛
Package
@carbon/react
Browser
Chrome
Package version
v1.49.0
React version
v18.2.0
Description
In the findIndex function here
carbon/packages/react/src/components/Menu/Menu.tsx
Line 237 in e70f08d
It tries to use
contains
against the current ref value without checking that the ref value is not null.During our automations this is throwing the following error
Cannot read properties of null (reading 'contains')
asitem.ref.current
is null .This requires just a simple check to ensure that the value is not
null
before callingcontains
Reproduction/example
NA
Steps to reproduce
Hard to reproduce consistently manually as it only really happens when the interaction is very fast, but it has been possible to see this consistently in automations.
The key part to the issue is that the submenu items are being created in async manner, so the refs are not being maintained.
Suggested Severity
Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.
Application/PAL
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: