Skip to content

feat(scatter-plot): right-click context menu (Copy ID, View in UniProt)#233

Draft
jcoludar wants to merge 1 commit into
mainfrom
feat/scatter-context-menu
Draft

feat(scatter-plot): right-click context menu (Copy ID, View in UniProt)#233
jcoludar wants to merge 1 commit into
mainfrom
feat/scatter-context-menu

Conversation

@jcoludar
Copy link
Copy Markdown
Collaborator

Summary

  • Adds protspace-context-menu Lit element registered in packages/core/src/components/scatter-plot/.
  • Wires it into protspace-scatterplot via a @contextmenu listener on the plot container; right-clicking a point opens a small menu.
  • Two built-in actions, no app changes required:
    • Copy IDnavigator.clipboard.writeText(proteinId)
    • View in UniProt — opens https://www.uniprot.org/uniprotkb/{id}/entry in a new tab; disabled when the id is not a UniProt accession.
  • Also dispatches a context-menu-action CustomEvent on the host for consumers that want to extend with app-level actions later.
  • Click-outside detection uses event.composedPath() so it works correctly across nested shadow DOMs (the host scatter-plot lives inside its own shadow root).

Why this PR

Spun out of #231. After taking #232 as the path forward for the publication-export work, the right-click context menu is the one piece from #231 that's orthogonal to the export modal and useful on its own. Everything else in #231 is being dropped.

Test plan

  • pnpm type-check (clean)
  • pnpm test — added 3-test suite for resolveMenuItems (hit / no-hit / no-accession), 588 tests total pass
  • pnpm lint — no new warnings
  • pnpm build and pnpm docs:build (pre-commit)
  • Manual: right-click a point, verify menu appears at cursor; click "Copy ID" and paste; click "View in UniProt" and confirm tab opens; right-click empty space and confirm no menu; click outside menu and confirm it closes; press Escape and confirm it closes.

Adds a `protspace-context-menu` Lit element wired into `protspace-scatterplot`
via a `@contextmenu` listener on the plot container. Right-clicking a point
opens a small menu with two actions:

- Copy ID — writes the protein id to the clipboard
- View in UniProt — opens the UniProt entry in a new tab (disabled when the
  id is not a UniProt accession)

The menu also dispatches a `context-menu-action` CustomEvent on the host so
consumers can extend with app-level actions later. Click-outside detection
uses `composedPath()` to work correctly across nested shadow DOMs.

Includes a unit test for `resolveMenuItems` covering hit/no-hit and
disabled-on-no-accession paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant