Skip to content

Commit

Permalink
fix(Input): listen change event of Input (#1595)
Browse files Browse the repository at this point in the history
* fix(pagination): remove placeholder of Pagionation Jumper

* fix(Input): listen change event of Input

Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin committed Dec 2, 2021
1 parent 327e712 commit 2c86cc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useCallback, useMemo } from 'react';
import classNames from 'classnames';
import { InputProps } from './interface';
import usePrefixCls from '../utils/hooks/use-prefix-cls';
import useControlledState from '../utils/hooks/useControlledState';

const Input = React.forwardRef<HTMLSpanElement, InputProps>((props, ref) => {
const {
Expand All @@ -15,11 +16,14 @@ const Input = React.forwardRef<HTMLSpanElement, InputProps>((props, ref) => {
onPressEnter,
onKeyPress,
style,
value,
value: valueProp,
defaultValue,
inputRef: propsInputRef,
...rest
} = props;

const [value, setValue] = useControlledState(valueProp, Array.isArray(defaultValue) ? undefined : defaultValue);

const prefixCls = usePrefixCls('input', customizePrefixCls);
const inputClass = useMemo(
() =>
Expand Down Expand Up @@ -77,6 +81,7 @@ const Input = React.forwardRef<HTMLSpanElement, InputProps>((props, ref) => {
{...rest}
value={value ?? ''}
disabled={disabled}
onChange={(event) => setValue(event.target.value)}
onKeyPress={handleKeyPress}
placeholder={placeholder}
ref={propsInputRef}
Expand Down
1 change: 0 additions & 1 deletion src/pagination/QuickJumper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const QuickJumper: React.FC<{
max={maxPages}
size="small"
className={`${prefixCls}__jumper__input`}
placeholder=" "
onKeyDown={({ key, currentTarget }) => {
if (key === 'Enter') {
onQuickGo?.(Number.parseInt(`${currentTarget.value}`, 10));
Expand Down

1 comment on commit 2c86cc8

@vercel
Copy link

@vercel vercel bot commented on 2c86cc8 Dec 2, 2021

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.