Skip to content

#9671 Context menu works wrong for embedded Ketcher#9672

Open
Copilot wants to merge 6 commits intomasterfrom
copilot/fix-context-menu-issues
Open

#9671 Context menu works wrong for embedded Ketcher#9672
Copilot wants to merge 6 commits intomasterfrom
copilot/fix-context-menu-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

How the feature works? / How did you fix the issue?

Embedded Ketcher was handling contextmenu too broadly: right-clicks outside the editor were getting suppressed, and the suppression could remain after the editor was unmounted. This change scopes the handler to the active Ketcher root only, so host-page context menus work normally outside the editor and after teardown.

  • Context menu scoping

    • Ignore contextmenu events unless the event target belongs to the current connected Ketcher root.
    • Fall back to canvas containment only when no connected root is available.
  • Unmount safety

    • Treat a detached root as inactive, preventing a stale listener from suppressing host-page right clicks after Ketcher is removed.
  • Regression coverage

    • Added unit coverage for:
      • events outside the Ketcher root
      • events after the Ketcher root is removed
      • existing inside-Ketcher right-click behavior
let isEventInsideKetcher = false;

if (eventTarget instanceof Node) {
  const connectedRoot = this.ketcherRootElement?.isConnected
    ? this.ketcherRootElement
    : null;

  if (connectedRoot) {
    isEventInsideKetcher = connectedRoot.contains(eventTarget);
  } else if (this.canvas.isConnected) {
    isEventInsideKetcher = this.canvas.contains(eventTarget);
  }
}

if (!isEventInsideKetcher) {
  return;
}

Embedded Ketcher context menu verification

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

@AlexeyGirin AlexeyGirin marked this pull request as ready for review April 4, 2026 23:42
@auto-assign auto-assign bot requested a review from svvald April 4, 2026 23:42
Copilot AI changed the title [WIP] Fix context menu functionality for embedded Ketcher Context menu works wrong for embedded Ketcher Apr 4, 2026
Copilot AI requested a review from AlexeyGirin April 4, 2026 23:46
@AlexeyGirin AlexeyGirin changed the title Context menu works wrong for embedded Ketcher #9671 Context menu works wrong for embedded Ketcher Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context menu works wrong for embedded Ketcher

2 participants