Skip to content

Commit

Permalink
fix: Search ios clear
Browse files Browse the repository at this point in the history
  • Loading branch information
linjinze999 committed Dec 19, 2024
1 parent 36e66e3 commit 197bfd3
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions packages/hippy_ui_react/src/components/Search/renderInfo.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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:
Expand All @@ -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: {
Expand Down

0 comments on commit 197bfd3

Please sign in to comment.