Skip to content

Commit

Permalink
fix(components): 修复PasswordInput组件onSubmit执行问题以及优化事件判断
Browse files Browse the repository at this point in the history
  • Loading branch information
lzm0x219 committed Dec 7, 2021
1 parent ff04288 commit e985208
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/react-vant/src/password-input/PasswordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ const PasswordInput = forwardRef<PasswordInputInstance, PasswordInputProps>((pro
const handleChange = (e) => {
const val = e.target.value;
innerEffect.current = true;
formatValue(val, (v: string) => {
if (isFunction(props.onChange)) props.onChange(v);
});
formatValue(val, props?.onChange);
};

const renderPoints = () => {
Expand Down Expand Up @@ -119,7 +117,7 @@ const PasswordInput = forwardRef<PasswordInputInstance, PasswordInputProps>((pro
useEffect(() => {
if (state.code.length >= props.length) {
inputRef?.current?.blur?.();
props.onSubmit(state.code);
props?.onSubmit(state.code);
}
}, [state.code]);

Expand Down Expand Up @@ -157,7 +155,7 @@ const PasswordInput = forwardRef<PasswordInputInstance, PasswordInputProps>((pro
onChange={handleChange}
onFocus={() => {
updateState({ focused: true });
if (isFunction(props.onFocus)) props.onFocus();
props?.onFocus();
}}
onBlur={() => updateState({ focused: false })}
/>
Expand Down

0 comments on commit e985208

Please sign in to comment.