Repository: adobe/react-spectrum
File: packages/@react-aria/interactions/src/usePress.ts (TypeScript)

Code before:
    triggerClick,
    triggerSyntheticClick
  ]);

  // Avoid onClick delay for double tap to zoom by default.
  useEffect(() => {
    if (process.env.NODE_ENV === 'test') {
      return;
    }

    const ownerDocument = getOwnerDocument(domRef?.current);
    const styleId = 'react-aria-pressable-style';
    if (ownerDocument && ownerDocument.head && !ownerDocument.getElementById(styleId)) {
      const style = ownerDocument.createElement('style');
      style.id = styleId;
      // touchAction: 'manipulation' is supposed to be equivalent, but in 
      // Safari it causes onPointerCancel not to fire on scroll.
      // https://bugs.webkit.org/show_bug.cgi?id=240917
      style.textContent = `
@layer {
  [data-react-aria-pressable] {
    touch-action: pan-x pan-y pinch-zoom;
  }
}
      `.trim();
      ownerDocument.head.prepend(style);
    }
  }, [domRef]);

  // Remove user-select: none in case component unmounts immediately after pressStart
  useEffect(() => {
    let state = ref.current;
    return () => {
      if (!allowTextSelectionOnPress) {
        restoreTextSelection(state.target ?? undefined);
      }
      for (let dispose of state.disposables) {
        dispose();
      }
      state.disposables = [];
    };
  }, [allowTextSelectionOnPress]);

  return {
    isPressed: isPressedProp || isPressed,
    pressProps: mergeProps(domProps, pressProps, {'data-react-aria-pressable': true})
  };
}

function isHTMLAnchorLink(target: Element): target is HTMLAnchorElement {
  return target.tagName === 'A' && target.hasAttribute('href');

Review comment (suggestion):
Maybe also skip this if `meta[name="viewport"][content="width=device-width"]` exists?

Also, while probably not important, just wanted to note we are running this even if `domRef` is not mounted yet, which we previously weren't.

Code after:
    triggerPressStart,
    triggerPressUp,
    triggerClick,
    triggerSyntheticClick
  ]);

  // Avoid onClick delay for double tap to zoom by default.
  useEffect(() => {
    if (!domRef || process.env.NODE_ENV === 'test') {
      return;
    }

    const ownerDocument = getOwnerDocument(domRef.current);
    if (!ownerDocument || !ownerDocument.head || ownerDocument.getElementById(STYLE_ID)) {
      return;
    }

    const style = ownerDocument.createElement('style');
    style.id = STYLE_ID;
    // touchAction: 'manipulation' is supposed to be equivalent, but in
    // Safari it causes onPointerCancel not to fire on scroll.
    // https://bugs.webkit.org/show_bug.cgi?id=240917
    style.textContent = `
@layer {
  [${PRESSABLE_ATTRIBUTE}] {
    touch-action: pan-x pan-y pinch-zoom;
  }
}
    `.trim();
    ownerDocument.head.prepend(style);
  }, [domRef]);

  // Remove user-select: none in case component unmounts immediately after pressStart
  useEffect(() => {
    let state = ref.current;
    return () => {
      if (!allowTextSelectionOnPress) {
        restoreTextSelection(state.target ?? undefined);
      }
      for (let dispose of state.disposables) {
        dispose();
      }
      state.disposables = [];
    };
  }, [allowTextSelectionOnPress]);

  return {
    isPressed: isPressedProp || isPressed,
    pressProps: mergeProps(domProps, pressProps, {[PRESSABLE_ATTRIBUTE]: true})
  };
}