Skip to content

fix(block-context-menu): prevent menu position sticking when triggered multiple times#4609

Merged
zbeyens merged 6 commits intoudecode:mainfrom
electroluxcode:fix/block-context-menu-stick
Sep 8, 2025
Merged

fix(block-context-menu): prevent menu position sticking when triggered multiple times#4609
zbeyens merged 6 commits intoudecode:mainfrom
electroluxcode:fix/block-context-menu-stick

Conversation

@electroluxcode
Copy link
Collaborator

fix #4608

Checklist

  • yarn typecheck
  • yarn lint:fix
  • yarn test
  • yarn brl
  • yarn changeset
  • ui changelog

Problem

When users right-click to trigger the block context menu multiple times in different locations, the menu position gets stuck at the first trigger location instead of updating to the new click position. This affects both:

  1. Block draggable area - menu stays at first right-click position
  2. Content area - menu position doesn't update on subsequent right-clicks

Root Cause

The ContextMenuContent was being rendered immediately without proper state management, causing the menu to render at the initial position and not re-render when the position changes.

Solution

  • Added usePluginOption to track menu open state
  • Wrapped ContextMenuContent with conditional rendering based on isOpen state
  • Added setTimeout to ensure proper timing for menu positioning

Changes

  • Before: Menu position sticks to first right-click location
  • After: Menu position updates correctly on each right-click

Files Modified

  • apps/www/src/registry/ui/block-context-menu.tsx
  • templates/plate-playground-template/src/components/ui/block-context-menu.tsx

@vercel
Copy link

vercel bot commented Sep 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
plate Ready Ready Preview Comment Sep 8, 2025 10:26am

@changeset-bot
Copy link

changeset-bot bot commented Sep 7, 2025

⚠️ No Changeset found

Latest commit: 29afb9b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working plate-ui labels Sep 7, 2025
@codesandbox
Copy link

codesandbox bot commented Sep 7, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@electroluxcode electroluxcode marked this pull request as draft September 8, 2025 02:26
electroluxcode and others added 2 commits September 8, 2025 18:05
…ntext-menu.tsx

Co-authored-by: Ziad Beyens <ziad.beyens@gmail.com>
Co-authored-by: Ziad Beyens <ziad.beyens@gmail.com>
@zbeyens zbeyens merged commit f612334 into udecode:main Sep 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working plate-ui size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

block-context-menu position sticking when triggered multiple times

2 participants