diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 4d310b4a..072f0efa 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -9,9 +9,10 @@ import type { TextInputKeyPressEventData, TextInputFocusEventData, TextInputContentSizeChangeEventData, + GestureResponderEvent, } from 'react-native'; import React, {useEffect, useRef, useCallback, useMemo, useLayoutEffect} from 'react'; -import type {CSSProperties, MutableRefObject, ReactEventHandler, FocusEventHandler, MouseEvent, KeyboardEvent, SyntheticEvent, ClipboardEventHandler} from 'react'; +import type {CSSProperties, MutableRefObject, ReactEventHandler, FocusEventHandler, MouseEvent, KeyboardEvent, SyntheticEvent, ClipboardEventHandler, TouchEvent} from 'react'; import {StyleSheet} from 'react-native'; import {updateInputStructure} from './web/utils/parserUtils'; import InputHistory from './web/InputHistory'; @@ -591,6 +592,14 @@ const MarkdownTextInput = React.forwardRef( divRef.current = r as MarkdownTextInputElement; }; + const handleTouchStart = (event: TouchEvent) => { + if (!onTouchStart) { + return; + } + const e = event as unknown as GestureResponderEvent; + onTouchStart(e); + }; + useClientEffect( function parseAndStyleValue() { if (!divRef.current || value === divRef.current.value) { @@ -677,7 +686,7 @@ const MarkdownTextInput = React.forwardRef( dir={dir} inputMode={inputMode} onSelect={updateSelection} - onTouchStart={onTouchStart} + onTouchStart={handleTouchStart} /> ); },