Skip to content

Conversation

VipinDevelops
Copy link
Member

@VipinDevelops VipinDevelops commented Sep 26, 2025

Description

This PR adds logic to use the active modal utility, preventing the issue peek view from closing unexpectedly.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots and Media (if applicable)

Screen.Recording.2025-09-26.at.6.40.59.PM.mov

Test Scenarios

References

Summary by CodeRabbit

  • New Features

    • Block menu now activates a side menu dropbar when opened via the drag handle for quicker access to actions.
  • Bug Fixes

    • Menu reliably closes on outside click, Escape, or scroll, preventing lingering UI.
    • After performing an action (e.g., delete, duplicate), the menu now auto-closes and cleans up the side menu dropbar.
    • Improved consistency of menu animations and state transitions during open/close.
    • Reduced unintended event propagation from menu item clicks for more predictable behavior.

@VipinDevelops VipinDevelops requested review from Copilot and aaryan610 and removed request for Copilot September 26, 2025 13:12
Copy link

makeplane bot commented Sep 26, 2025

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

Walkthrough

The block menu now adds the SIDE_MENU dropbar extension on drag-handle activation and removes it when the menu closes or on Escape/outside-click/scroll. Menu item clicks are wrapped to invoke the action, then close the menu and remove the extension. Types are updated to allow SIDE_MENU in active dropbar extensions.

Changes

Cohort / File(s) Change Summary
Block menu behavior and event handling
packages/editor/src/core/components/menus/block-menu.tsx
Adds/removes SIDE_MENU dropbar extension on menu open/close; updates outside-click, keydown (Escape), and scroll handlers to remove extension; refactors menu item onClick flow to call action then close and clean up; updates handler dependencies and effect cleanup.
Dropbar extension typing
packages/editor/src/core/extensions/utility.ts
Extends TActiveDropbarExtensions to include CORE_EXTENSIONS.SIDE_MENU, enabling add/remove APIs to accept the new extension.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant DragHandle as Drag Handle
  participant BlockMenu as Block Menu
  participant Editor as Editor.commands
  participant Dropbar as ActiveDropbarExtensions

  User->>DragHandle: Click
  DragHandle->>BlockMenu: Open menu
  BlockMenu->>Editor: addActiveDropbarExtension(SIDE_MENU)
  Editor->>Dropbar: SIDE_MENU active

  alt Outside click / Esc / Scroll
    User->>BlockMenu: Dismiss interaction
    BlockMenu->>Editor: removeActiveDropbarExtension(SIDE_MENU)
    BlockMenu-->>User: Close menu
  end

  rect rgba(230,245,255,0.5)
  note right of BlockMenu: Menu item click flow
  User->>BlockMenu: Click menu item
  BlockMenu->>BlockMenu: Invoke item onClick
  BlockMenu->>Editor: removeActiveDropbarExtension(SIDE_MENU)
  BlockMenu-->>User: Close menu and stop propagation
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

🐛bug, 🌐frontend, ✍️editor

Suggested reviewers

  • Palanikannan1437
  • sriramveeraghanta

Poem

A twitch of the whiskers, a hop and a view,
The side menu slides in—then neatly bids adieu.
Clicks go “thump,” actions spring true,
Escape whispers hush, and scroll breezes through.
Carrot-coded cleanup, tidy and new. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description section clearly explains the purpose of the change, and the Type of Change and Screenshots sections are properly filled out, but the Test Scenarios and References headings remain empty placeholders and lack the required details on verification steps and related issue links. Please populate the Test Scenarios section with the specific steps you performed to verify the fix and add any relevant issue numbers or links in the References section to complete the template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely highlights the main fix by referencing the unexpected closing of the peek view when interacting with block menu options, matching the primary change implemented in this pull request.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-embed_peak_close

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@VipinDevelops VipinDevelops added ✍️editor 🐛bug Something isn't working labels Sep 26, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
packages/editor/src/core/components/menus/block-menu.tsx (4)

73-85: Stabilize hook deps to prevent unnecessary re-binding.

Using editor.commands in deps can be unstable and cause listener churn. Prefer editor (which is stable) in the deps for handleClickDragHandle.

Apply:

-    [editor.commands, refs]
+    [editor, refs]

87-99: Ensure SIDE_MENU is always cleared on close/unmount.

You clear the extension on several events, but if the menu closes via other paths or the component unmounts while open, SIDE_MENU may remain active. Add explicit cleanup in the effect and a small watcher on isOpen.

Add cleanup on unmount:

   return () => {
     document.removeEventListener("click", handleClickDragHandle);
     document.removeEventListener("contextmenu", handleClickDragHandle);
     document.removeEventListener("keydown", handleKeyDown);
     document.removeEventListener("scroll", handleScroll, true);
+    // Ensure SIDE_MENU is not left active on unmount
+    editor.commands.removeActiveDropbarExtension(CORE_EXTENSIONS.SIDE_MENU);
   };

Also add a watcher so any close path clears it:

+  // Ensure SIDE_MENU is cleared whenever the menu closes via any path
+  useEffect(() => {
+    if (!isOpen) {
+      editor.commands.removeActiveDropbarExtension(CORE_EXTENSIONS.SIDE_MENU);
+    }
+  }, [isOpen, editor]);

Also applies to: 104-111


110-110: Use editor (not editor.commands) in effect deps.

Prevents unnecessary add/remove of global listeners if commands proxy is non-stable.

-  }, [editor.commands, handleClickDragHandle]);
+  }, [editor, handleClickDragHandle]);

223-229: Call preventDefault/stopPropagation before executing item action.

Prevents any default/bubbling side-effects from firing before the action runs.

-              onClick={(e) => {
-                item.onClick(e);
-                e.preventDefault();
-                e.stopPropagation();
-                setIsOpen(false);
-                editor.commands.removeActiveDropbarExtension(CORE_EXTENSIONS.SIDE_MENU);
-              }}
+              onClick={(e) => {
+                e.preventDefault();
+                e.stopPropagation();
+                item.onClick(e);
+                setIsOpen(false);
+                editor.commands.removeActiveDropbarExtension(CORE_EXTENSIONS.SIDE_MENU);
+              }}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bedc1fa and a0c4e7d.

📒 Files selected for processing (2)
  • packages/editor/src/core/components/menus/block-menu.tsx (3 hunks)
  • packages/editor/src/core/extensions/utility.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/editor/src/core/extensions/utility.ts (1)

14-20: Approve SIDE_MENU addition
TAdditionalActiveDropbarExtensions is defined as never, so adding CORE_EXTENSIONS.SIDE_MENU introduces no duplicate union.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working ✍️editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant