Skip to content

Commit

Permalink
fix(InputItem): money input should support disabled, editable
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoidjk authored and lixiaoyang1992 committed Apr 26, 2018
1 parent 3b57a76 commit 3d788d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
20 changes: 12 additions & 8 deletions components/input-item/CustomInput.web.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* tslint:disable:jsx-no-multiline-js */
import React from 'react';
import CustomKeyboard from './CustomKeyboard.web';

Expand Down Expand Up @@ -101,23 +102,26 @@ class NumberInput extends React.Component<any, any> {
}

render() {
const { placeholder, value, keyboardPrefixCls } = this.props;
const { placeholder, value, keyboardPrefixCls, disabled, editable } = this.props;
const { focused } = this.state;
const preventKeyboard = disabled || !editable;
return (<div className="fake-input-container">
{value === '' && <div className="fake-input-placeholder">{placeholder}</div>}
<div
className={focused ? 'fake-input focus' : 'fake-input'}
ref="input-container"
onClick={this.onFakeInputClick}
onClick={preventKeyboard ? () => {} : this.onFakeInputClick}
>
{value}
</div>
<CustomKeyboard
onClick={this.onKeyboardClick}
hide={!focused}
confirmDisabled={value === ''}
preixCls={keyboardPrefixCls}
/>
{!preventKeyboard &&
<CustomKeyboard
onClick={this.onKeyboardClick}
hide={!focused}
confirmDisabled={value === ''}
preixCls={keyboardPrefixCls}
/>
}
</div>);
}
}
Expand Down
1 change: 1 addition & 0 deletions components/input-item/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class InputItem extends React.Component<InputItemProps, any> {
onFocus={this.onInputFocus}
onBlur={this.onInputBlur}
disabled={disabled}
editable={editable}
value={fixControlledValue(value)}
{...(this.props.focused !== undefined ? { focused: this.props.focused } : {})}
{...(this.props.autoFocus !== undefined ? { autoFocus: this.props.autoFocus } : {})}
Expand Down

0 comments on commit 3d788d0

Please sign in to comment.