fix: Context menu submenu offset incorrect for last item#3262
fix: Context menu submenu offset incorrect for last item#3262dblythy wants to merge 2 commits intoparse-community:alphafrom
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughReplaces layout effects and refines submenu positioning in the context menu: Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/ContextMenu/ContextMenu.react.js`:
- Around line 128-132: The code assumes parentElement =
itemElement.closest('ul') is non-null; add a defensive null guard in the handler
around closest('ul') used in ContextMenu.react.js so we don't call
getBoundingClientRect on null: check if parentElement is truthy after calling
itemElement.closest('ul') (or return early) before computing parentRect,
itemOffset and calling setPath(newPath, itemOffset); reference itemElement,
parentElement, itemRect, parentRect and setPath/newPath to locate and update the
block.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6054894d-ec84-40c2-bb5f-dc74c2773c5c
📒 Files selected for processing (1)
src/components/ContextMenu/ContextMenu.react.js
Prevent potential TypeError when parentElement is null by checking
the result of closest('ul') before calling getBoundingClientRect.
|
Please include a screenshot or video of the implemented UI change (before vs. after). |
Closes #2635
Summary
useLayoutEffectinstead ofuseEffectfor submenu position calculation to prevent flash at wrong position before repositioningopacity: 0initial style when position hasn't been calculated yetoffsetTopwithgetBoundingClientRectfor more robust offset measurementSummary by CodeRabbit