Skip to content

[Web]: (feature/docs) Disable the context menu from browser. #78671

@y0nd0

Description

@y0nd0

Since I found not no docs and no help on forums, etc. We should clarify that here:

How to disable the context menu of the browser when right click or long press (browser, on touch press release)?

In JavaScript it's:

document.body.addEventListener('contextmenu', (evemt) => {
  event.preventDefault();
});

But how to do this in Flutter (2.x, Web)?
If this feature is missing: Here's the feature request: Implement the possibility to disable the context menu. No workaround like blocking right click, please. Because it also appears on mobile long press.

Ok, I could disable the context menu when deploy the flutter app. Because it's just an index.html with the flutter JS / Canvas etc. But how to access the html during debugging / coding?
E.g. is there a way to inject JavaScript? But note: It should also work (ignored) as native mobile app.

Btw. Flutter should disable the browser context menu by default. Because there is nothing to select. It's jsut the canvas.

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityf: gesturesflutter/packages/flutter/gestures repository.found in release: 2.1Found to occur in 2.1frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions