Home / Function/ constructSelectEvent() — react Function Reference

constructSelectEvent() — react Function Reference

Architecture documentation for the constructSelectEvent() function in SelectEventPlugin.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4c50b416_304e_a759_8f8d_e22e46f2d54d["constructSelectEvent()"]
  b8a5c95d_02fb_4719_0efd_4463f2546996["SelectEventPlugin.js"]
  4c50b416_304e_a759_8f8d_e22e46f2d54d -->|defined in| b8a5c95d_02fb_4719_0efd_4463f2546996
  883c6b61_d9b7_7c94_1745_bb9ecdd3ccdb["extractEvents()"]
  883c6b61_d9b7_7c94_1745_bb9ecdd3ccdb -->|calls| 4c50b416_304e_a759_8f8d_e22e46f2d54d
  5b2e1567_4290_cb01_a9ed_fdc2831b91e8["getEventTargetDocument()"]
  4c50b416_304e_a759_8f8d_e22e46f2d54d -->|calls| 5b2e1567_4290_cb01_a9ed_fdc2831b91e8
  73ae0fb8_77c3_8d4a_406e_dfdbac35c58c["getActiveElement()"]
  4c50b416_304e_a759_8f8d_e22e46f2d54d -->|calls| 73ae0fb8_77c3_8d4a_406e_dfdbac35c58c
  ab574a65_e1cf_4bff_0d86_6d96e2a1fa23["getSelection()"]
  4c50b416_304e_a759_8f8d_e22e46f2d54d -->|calls| ab574a65_e1cf_4bff_0d86_6d96e2a1fa23
  dd9eb6ac_296c_ca63_51dd_da82f645aaaa["accumulateTwoPhaseListeners()"]
  4c50b416_304e_a759_8f8d_e22e46f2d54d -->|calls| dd9eb6ac_296c_ca63_51dd_da82f645aaaa
  style 4c50b416_304e_a759_8f8d_e22e46f2d54d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js lines 94–134

function constructSelectEvent(
  dispatchQueue: DispatchQueue,
  nativeEvent: AnyNativeEvent,
  nativeEventTarget: null | EventTarget,
) {
  // Ensure we have the right element, and that the user is not dragging a
  // selection (this matches native `select` event behavior). In HTML5, select
  // fires only on input and textarea thus if there's no focused element we
  // won't dispatch.
  const doc = getEventTargetDocument(nativeEventTarget);

  if (
    mouseDown ||
    activeElement == null ||
    activeElement !== getActiveElement(doc)
  ) {
    return;
  }

  // Only fire when selection has actually changed.
  const currentSelection = getSelection(activeElement);
  if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
    lastSelection = currentSelection;

    const listeners = accumulateTwoPhaseListeners(
      activeElementInst,
      'onSelect',
    );
    if (listeners.length > 0) {
      const event: ReactSyntheticEvent = new SyntheticEvent(
        'onSelect',
        'select',
        null,
        nativeEvent,
        nativeEventTarget,
      );
      dispatchQueue.push({event, listeners});
      event.target = activeElement;
    }
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does constructSelectEvent() do?
constructSelectEvent() is a function in the react codebase, defined in packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js.
Where is constructSelectEvent() defined?
constructSelectEvent() is defined in packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js at line 94.
What does constructSelectEvent() call?
constructSelectEvent() calls 4 function(s): accumulateTwoPhaseListeners, getActiveElement, getEventTargetDocument, getSelection.
What calls constructSelectEvent()?
constructSelectEvent() is called by 1 function(s): extractEvents.

Analyze Your Own Codebase

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

Try Supermodel Free