Home / Function/ contextmenu() — react Function Reference

contextmenu() — react Function Reference

Architecture documentation for the contextmenu() function in domEventSequences.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  6e92fb29_1b7c_e506_23d4_54a296376a58["contextmenu()"]
  d4066e75_dcea_2912_73ff_88e30b9530d2["domEventSequences.js"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|defined in| d4066e75_dcea_2912_73ff_88e30b9530d2
  740d07e9_1d74_f59f_1935_e8c1234007af["contextmenu()"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|calls| 740d07e9_1d74_f59f_1935_e8c1234007af
  010da236_784b_cbe9_c79d_2a93e35a2880["hasPointerEvent()"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|calls| 010da236_784b_cbe9_c79d_2a93e35a2880
  9d0dad3b_5733_de1f_1a31_75b5db0ccd25["pointerdown()"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|calls| 9d0dad3b_5733_de1f_1a31_75b5db0ccd25
  e34ccbc5_59a5_f36e_988d_f8b3d9276499["createTouch()"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|calls| e34ccbc5_59a5_f36e_988d_f8b3d9276499
  52771804_c0eb_2d50_479d_4a901e3c442f["addTouch()"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|calls| 52771804_c0eb_2d50_479d_4a901e3c442f
  0dab3578_90b3_815b_5690_5f9eec1a66ca["createTouchEventPayload()"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|calls| 0dab3578_90b3_815b_5690_5f9eec1a66ca
  b8c4882b_a73c_720b_5b95_bc0ff3d0452d["touchstart()"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|calls| b8c4882b_a73c_720b_5b95_bc0ff3d0452d
  50f207cf_f1ef_284f_520d_b159fc0f8b6b["removeTouch()"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|calls| 50f207cf_f1ef_284f_520d_b159fc0f8b6b
  31c8047d_4ef8_b203_4044_8d36bec78431["mousedown()"]
  6e92fb29_1b7c_e506_23d4_54a296376a58 -->|calls| 31c8047d_4ef8_b203_4044_8d36bec78431
  style 6e92fb29_1b7c_e506_23d4_54a296376a58 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/dom-event-testing-library/domEventSequences.js lines 110–173

export function contextmenu(
  target,
  defaultPayload,
  {pointerType = 'mouse', modified} = {},
) {
  const dispatch = arg => target.dispatchEvent(arg);

  const payload = {
    pointerId: defaultPointerId,
    pointerType,
    ...defaultPayload,
  };

  const preventDefault = payload.preventDefault;

  if (pointerType === 'touch') {
    if (hasPointerEvent()) {
      dispatch(
        domEvents.pointerdown({
          ...payload,
          button: buttonType.primary,
          buttons: buttonsType.primary,
        }),
      );
    }
    const touch = createTouch(target, payload);
    touchStore.addTouch(touch);
    const touchEventPayload = createTouchEventPayload(target, touch, payload);
    dispatch(domEvents.touchstart(touchEventPayload));
    dispatch(
      domEvents.contextmenu({
        button: buttonType.primary,
        buttons: buttonsType.none,
        preventDefault,
      }),
    );
    touchStore.removeTouch(touch);
  } else if (pointerType === 'mouse') {
    if (modified === true) {
      const button = buttonType.primary;
      const buttons = buttonsType.primary;
      const ctrlKey = true;
      if (hasPointerEvent()) {
        dispatch(
          domEvents.pointerdown({button, buttons, ctrlKey, pointerType}),
        );
      }
      dispatch(domEvents.mousedown({button, buttons, ctrlKey}));
      if (platform.get() === 'mac') {
        dispatch(
          domEvents.contextmenu({button, buttons, ctrlKey, preventDefault}),
        );
      }
    } else {
      const button = buttonType.secondary;
      const buttons = buttonsType.secondary;
      if (hasPointerEvent()) {
        dispatch(domEvents.pointerdown({button, buttons, pointerType}));
      }
      dispatch(domEvents.mousedown({button, buttons}));
      dispatch(domEvents.contextmenu({button, buttons, preventDefault}));
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does contextmenu() do?
contextmenu() is a function in the react codebase, defined in packages/dom-event-testing-library/domEventSequences.js.
Where is contextmenu() defined?
contextmenu() is defined in packages/dom-event-testing-library/domEventSequences.js at line 110.
What does contextmenu() call?
contextmenu() calls 9 function(s): addTouch, contextmenu, createTouch, createTouchEventPayload, hasPointerEvent, mousedown, pointerdown, removeTouch, and 1 more.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free