Skip to content

Commit

Permalink
fix(InputButton): handle events (#1841)
Browse files Browse the repository at this point in the history
Co-authored-by: Zhang Rui <zhangrui@growingio.com>
  • Loading branch information
Ryan Zhang and Zhang Rui committed Feb 14, 2022
1 parent 37167f8 commit 2b14866
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
9 changes: 1 addition & 8 deletions src/input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ const Input = React.forwardRef<HTMLSpanElement, InputProps>((props, ref) => {
[onPressEnter, onKeyPress]
);

// const handleChange = useCallback(
// (e: React.ChangeEvent<HTMLInputElement>) => {
// onChange?.(e);
// },
// [onChange]
// );

const prefixFcCls = useMemo(
() =>
classNames(`${prefixCls}__prefix`, {
Expand Down Expand Up @@ -91,7 +84,7 @@ const Input = React.forwardRef<HTMLSpanElement, InputProps>((props, ref) => {
[suffixCls, customizeSuffix, eventRest]
);
return (
<span className={inputClass} style={style} ref={ref}>
<span className={inputClass} style={style} ref={ref} {...eventRest}>
{prefix}
<input
data-testid="input"
Expand Down
6 changes: 4 additions & 2 deletions src/input/InputButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ const InputButton = React.forwardRef<HTMLInputElement, InputButtonProps>((props,

const suffix = useMemo(() => {
const hideClear = allowClear === false;
const defaultSuffix = value && !hideClear && !disabled ? <CloseCircleFilled onClick={onClear} /> : <DownFilled />;
const { onClick } = rest;
const defaultSuffix =
value && !hideClear && !disabled ? <CloseCircleFilled onClick={onClear} /> : <DownFilled onClick={onClick} />;
return customizeSuffix || defaultSuffix;
}, [customizeSuffix, value, onClear, allowClear, disabled]);
}, [customizeSuffix, value, onClear, allowClear, disabled, rest]);

const styles = maxWidth ? { maxWidth } : {};

Expand Down
4 changes: 2 additions & 2 deletions src/input/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
display: inline-flex;
align-items: center;
justify-content: center;
margin-left: 8px;
padding-left: 8px;
cursor: pointer;
svg {
width: 14px;
Expand All @@ -97,7 +97,7 @@
display: inline-flex;
align-items: center;
justify-content: center;
margin-right: 8px;
padding-right: 8px;
cursor: pointer;
svg {
width: 14px;
Expand Down

1 comment on commit 2b14866

@vercel
Copy link

@vercel vercel bot commented on 2b14866 Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.