Skip to content

[WIKI-696] fix: peek view close on click block menu options#7861

Merged
pushya22 merged 3 commits intopreviewfrom
fix-embed_peak_close
Sep 30, 2025
Merged

[WIKI-696] fix: peek view close on click block menu options#7861
pushya22 merged 3 commits intopreviewfrom
fix-embed_peak_close

Conversation

@iam-vipin
Copy link
Member

@iam-vipin iam-vipin 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 opens a side-menu dropbar and registers it as an active dropbar extension for consistent behavior.
  • Bug Fixes

    • Menu consistently closes on outside click, Escape, or scroll to avoid lingering UI.
    • Menu auto-closes after actions (delete, duplicate) with smoother animations and state transitions.
    • Click handling for menu items centralized to prevent unintended event propagation and ensure reliable closing.

@iam-vipin iam-vipin requested review from aaryan610 and Copilot and removed request for Copilot September 26, 2025 13:12
@makeplane
Copy link

makeplane bot commented Sep 26, 2025

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Introduces explicit openBlockMenu and closeBlockMenu callbacks that register/unregister the SIDE_MENU via editor.commands and replaces direct isOpen toggles with these callbacks across drag-handle, outside-click, Escape, scroll, and menu-item click flows. Adds CORE_EXTENSIONS.SIDE_MENU to active dropbar extension types.

Changes

Cohort / File(s) Change Summary
Block menu behavior & event handling
packages/editor/src/core/components/menus/block-menu.tsx
Adds openBlockMenu / closeBlockMenu callbacks; routes all open/close interactions (drag-handle click, outside-click, Escape, scroll, menu item clicks) through these callbacks instead of direct setIsOpen; wraps menu item handlers to centralize preventDefault/stopPropagation and closing; updates effect dependencies and cleanup to include editor.commands and the new callbacks; preserves animation timing tied to isOpen.
Dropbar extension typing
packages/editor/src/core/extensions/utility.ts
Extends TActiveDropbarExtensions union to include CORE_EXTENSIONS.SIDE_MENU, allowing addActiveDropbarExtension/removeActiveDropbarExtension to accept the SIDE_MENU 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: call openBlockMenu
  BlockMenu->>Editor: addActiveDropbarExtension(SIDE_MENU)
  Editor->>Dropbar: SIDE_MENU active

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

  rect rgba(230,245,255,0.6)
  note right of BlockMenu: Menu item click (wrapped)
  User->>BlockMenu: Click menu item
  BlockMenu->>BlockMenu: invoke item.onClick (wrapped -> prevents propagation)
  BlockMenu->>Editor: removeActiveDropbarExtension(SIDE_MENU)
  BlockMenu-->>User: Close menu
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • aaryan610
  • Palanikannan1437

Poem

A twitch of whiskers, a quick menu hop,
SIDE_MENU springs open, then neatly stops.
Clicks wrapped kindly, escape clears the way,
Close with a hop—code tidy today. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description correctly fills the Description and Type of Change sections and provides a screenshot link under the appropriate heading, but it leaves the Test Scenarios section empty and omits any entries in References. Because the template calls for explicit test details and related links, these omissions mean the PR description is incomplete. Please add concrete test scenarios describing how the bug fix was verified and populate the References section with relevant issue or PR links to conform to the repository’s description template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title “[WIKI-696] fix: peek view close on click block menu options” directly describes the core issue addressed—preventing the peek view from closing when selecting block menu options—and includes the relevant ticket identifier. It is concise, specific to the main change, and avoids unnecessary details or generic phrasing, making it clear to reviewers what this PR fixes.
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

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 152a4dc and 6fbca9b.

📒 Files selected for processing (1)
  • packages/editor/src/core/components/menus/block-menu.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/editor/src/core/components/menus/block-menu.tsx
⏰ 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)

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.

@iam-vipin iam-vipin 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.

@iam-vipin iam-vipin changed the title [WIKI-696] fix: peak view close on click block menu options [WIKI-696] fix: peek view close on click block menu options Sep 29, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where peek view closes unexpectedly when clicking block menu options by implementing proper active modal utility management. The fix prevents unintended closing behavior by properly tracking the side menu state through the active dropbar extension system.

  • Adds SIDE_MENU to the active dropbar extensions type
  • Implements toggleBlockMenu function to manage side menu state consistently
  • Refactors menu item click handlers to prevent event propagation and ensure proper cleanup

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/editor/src/core/extensions/utility.ts Adds SIDE_MENU to active dropbar extensions type
packages/editor/src/core/components/menus/block-menu.tsx Implements proper state management with toggleBlockMenu and refactors event handlers

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 46 to 54
const toggleBlockMenu = useCallback(() => {
if (isOpen) {
setIsOpen(false);
editor.commands.removeActiveDropbarExtension(CORE_EXTENSIONS.SIDE_MENU);
} else {
setIsOpen(true);
editor.commands.addActiveDropbarExtension(CORE_EXTENSIONS.SIDE_MENU);
}
}, [editor, isOpen]);
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The function name toggleBlockMenu is misleading since it's being called in contexts where the menu should always be closed (like on Escape key or scroll). This could lead to unintended opening of the menu when it should only close.

Copilot uses AI. Check for mistakes.
Comment on lines 72 to 83
// Show the menu
setIsOpen(true);
toggleBlockMenu();
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Using toggleBlockMenu() here will close the menu if it's open, but open it if it's closed. Since this is in the drag handle click handler, it should only open the menu, not toggle it.

Copilot uses AI. Check for mistakes.
// If clicking outside and not on a menu item, hide the menu
if (menuRef.current && !menuRef.current.contains(target)) {
setIsOpen(false);
toggleBlockMenu();
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Using toggleBlockMenu() when clicking outside should only close the menu, not toggle it. This could accidentally open the menu when clicking outside.

Copilot uses AI. Check for mistakes.
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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

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

📒 Files selected for processing (1)
  • packages/editor/src/core/components/menus/block-menu.tsx (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/editor/src/core/components/menus/block-menu.tsx (1)
packages/editor/src/index.ts (1)
  • CORE_EXTENSIONS (16-16)
⏰ 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)

@pushya22 pushya22 merged commit 0ad439f into preview Sep 30, 2025
6 checks passed
@pushya22 pushya22 deleted the fix-embed_peak_close branch September 30, 2025 09:59
zy1000 pushed a commit to zy1000/plane that referenced this pull request Oct 1, 2025
…e#7861)

* fix: block close

* chore : add toggle option in block menu

* fix: separate methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants