(core) Show default context menu on link

Summary:
also:
  - closes opened menu if any when click on a custom widget
  - closes opened menu if any when F2

Test Plan: Include test case

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3269
This commit is contained in:
Cyprien P
2022-02-16 15:15:27 +01:00
parent f224afcc62
commit afa90cc365
6 changed files with 31 additions and 5 deletions

View File

@@ -24,6 +24,9 @@ export function gristLink(href: string|Observable<string>, ...args: IDomArgs<HTM
dom.attr("href", href),
dom.attr("target", "_blank"),
dom.on("click", ev => onClickHyperLink(ev, typeof href === 'string' ? href : href.get())),
// stop propagation to prevent the grist custom context menu to show up and let the default one
// to show up instead.
dom.on("contextmenu", ev => ev.stopPropagation()),
// As per Google and Mozilla recommendations to prevent opened links
// from running on the same process as Grist:
// https://developers.google.com/web/tools/lighthouse/audits/noopener