Skip to content

Cannot stop default behaviour of right click on context menu #6883

Description

@abarreau

What is the current behavior?

When giving a function to onContextMenu that is supposed to prevent native contextual menu from opening with e.preventDefault(), the contextual menu still opens.

const handleContextMenu = useCallback(
    (state: MouseHandlerDataParam, e: SyntheticEvent): void => {
      e.preventDefault();
      e.stopPropagation();
      console.log({ state, e });
    },
    []
  );

What is the expected behavior?

Contextual menu should not open.

Please provide a demo of the problem in a sandbox

https://stackblitz.com/edit/9cffydpy-9oasev4c?file=src%2FExample.tsx

Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?

Worked in v2+.
I'm using recharts v3.6.0 and vivaldi-browser v7.7.3851.66 (Official Build) (64-bit) Chromium Version 142.0.7444.245

Metadata

Metadata

Assignees

Labels

bugGeneral bug label

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions