react-component / react-component/menu

props.parentMenu is undefined

Open
#255 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
701
Forks
266
Avg merge
4d 11h
Merged PRs (30d)
3

Description

All of the sudden my application started crashing at node_modules/antd/node_modules/rc-menu/es/SubMenu.js:260

260 | var getPopupContainer = props.parentMenu.isRootMenu ? props.parentMenu.props.getPopupContainer : function (triggerNode) {
     return triggerNode.parentNode; 
};

with an error: TypeError: props.parentMenu is undefined

I fixed it by coalescing the undefined:

var getPopupContainer = props.parentMenu ? props.parentMenu.isRootMenu ? props.parentMenu.props.getPopupContainer : function (triggerNode) {
      return triggerNode.parentNode;
 } : null;

But I don't really know if that's the best way to do this. I'm using rc-menu as a dependency of antd library.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at node_modules/antd/node_modules/rc-menu/es/SubMenu.js around line 260 and trace how parentMenu is supplied when the crash occurs. Reproduce the failure through the reported antd dependency and compare it with the proposed null check. Done means identifying the valid parentMenu behavior and covering the resulting fix with the relevant project test or reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.