diff --git a/packages/hippy_ui_react/src/components/Search/renderInfo.tsx b/packages/hippy_ui_react/src/components/Search/renderInfo.tsx index 9085b5f..4f6e513 100644 --- a/packages/hippy_ui_react/src/components/Search/renderInfo.tsx +++ b/packages/hippy_ui_react/src/components/Search/renderInfo.tsx @@ -1,8 +1,8 @@ import React, { isValidElement } from 'react'; -import { Image, ViewStyle } from '@hippy/react'; +import { Image, ViewProps, ViewStyle } from '@hippy/react'; import { SearchRenderInfo, SearchRenderParams, searchConfig } from './config'; import { transferStyle } from '../../utils/Styles'; -import { getObjectType, ObjectType } from '../../utils/Utils'; +import { getObjectType, isWeb, ObjectType } from '../../utils/Utils'; /** Search:获取渲染信息 */ export default function getRenderInfo(params: SearchRenderParams): SearchRenderInfo { @@ -15,6 +15,24 @@ export default function getRenderInfo(params: SearchRenderParams): SearchRenderI const themeConfig = { ...searchConfig, ..._themeConfig }; const { wrapStyle, leftIconStyle, clearIconStyle, inputStyle } = getStyle(params); + const clearProps: ViewProps & { onMouseDown?: () => void } = isWeb() + ? { + onMouseDown: (e?: any) => { + onClear(); + (clearIcon as any)?.onMouseDown?.(e); + }, + onPressIn: (e?: any) => { + onClear(); + (clearIcon as any)?.onPressIn?.(e); + }, + } + : { + onClick(e) { + onClear(); + (clearIcon as any)?.onClear?.(e); + }, + }; + const result: SearchRenderInfo = { wrapProps: { ...wrapProps, style: wrapStyle }, leftIcon: @@ -32,14 +50,7 @@ export default function getRenderInfo(params: SearchRenderParams): SearchRenderI {...themeConfig.searchClearIconPropsFn(params)} {...(clearIcon as any)} style={clearIconStyle} - onMouseDown={(e?: any) => { - onClear(); - (clearIcon as any)?.onMouseDown?.(e); - }} - onPressIn={(e?: any) => { - onClear(); - (clearIcon as any)?.onPressIn?.(e); - }} + {...clearProps} /> ), inputProps: {