Skip to content

Commit

Permalink
fix: Field: 修复disabledonClickInput失效的问题 #149
Browse files Browse the repository at this point in the history
  • Loading branch information
3lang3 committed Nov 10, 2021
1 parent 588bf53 commit 2d681ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/react-vant/src/field/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const Field = forwardRef<FieldInstance, FieldProps>((props, ref) => {
};

const renderInput = () => {
const { type, error, name, rows, value, placeholder, disabled, readonly, onClickInput } = props;
const { type, error, name, rows, value, placeholder, disabled, readonly } = props;
const controlClass = bem('control', [
getProp('inputAlign'),
{
Expand All @@ -129,11 +129,7 @@ const Field = forwardRef<FieldInstance, FieldProps>((props, ref) => {
]);

if (props.children) {
return (
<div className={classnames(controlClass)} onClick={onClickInput}>
{props.children}
</div>
);
return <div className={classnames(controlClass)}>{props.children}</div>;
}

const handleChange = (e) => {
Expand Down Expand Up @@ -214,7 +210,6 @@ const Field = forwardRef<FieldInstance, FieldProps>((props, ref) => {
placeholder={placeholder || ''}
onBlur={handleBulr}
onFocus={handleFocus}
onClick={onClickInput}
onChange={handleChange}
onKeyPress={handleKeypress}
/>
Expand Down Expand Up @@ -249,7 +244,6 @@ const Field = forwardRef<FieldInstance, FieldProps>((props, ref) => {
placeholder={placeholder || ''}
onBlur={handleBulr}
onFocus={handleFocus}
onClick={onClickInput}
onChange={handleChange}
onKeyPress={handleKeypress}
/>
Expand Down Expand Up @@ -406,7 +400,9 @@ const Field = forwardRef<FieldInstance, FieldProps>((props, ref) => {
)}
>
<div className={classnames(bem('body'))}>
{renderInput()}
<div className={classnames(bem('control-wrapper'))} onClick={props.onClickInput}>
{renderInput()}
</div>
{showClear &&
(typeof props.clearIcon === 'string' ? (
<Icon
Expand Down
4 changes: 4 additions & 0 deletions packages/react-vant/src/field/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
align-items: center;
}

&__control-wrapper {
width: 100%;
}

&__control {
display: block;
box-sizing: border-box;
Expand Down

0 comments on commit 2d681ce

Please sign in to comment.