Skip to content

Commit

Permalink
fix issue #1437 money input support disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
pingan1927 committed Jun 18, 2017
1 parent c366b63 commit 4dd715a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 10 additions & 3 deletions components/input-item/CustomInput.web.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* tslint:disable:jsx-no-multiline-js */
import React from 'react';
import classNames from 'classnames';
import CustomKeyboard from './CustomKeyboard.web';

class NumberInput extends React.Component<any, any> {
Expand All @@ -9,6 +10,7 @@ class NumberInput extends React.Component<any, any> {
onBlur: () => {},
placeholder: '',
value: '',
disabled: false,
prefixCls: 'am-input',
keyboardPrefixCls: 'am-number-keyboard',
};
Expand Down Expand Up @@ -94,9 +96,9 @@ class NumberInput extends React.Component<any, any> {
}

onFakeInputClick = () => {
const { value } = this.props;
const { value, disabled } = this.props;
const { focused } = this.state;
if (!focused) {
if (!disabled && !focused) {
this.onInputFocus(value);
}
}
Expand All @@ -105,10 +107,15 @@ class NumberInput extends React.Component<any, any> {
const { placeholder, value, keyboardPrefixCls, disabled, editable } = this.props;
const { focused } = this.state;
const preventKeyboard = disabled || !editable;
const fakeInputCls = classNames({
[`fake-input`]: true,
[`focus`]: focused,
[`fake-input-disabled`]: preventKeyboard,
});
return (<div className="fake-input-container">
{value === '' && <div className="fake-input-placeholder">{placeholder}</div>}
<div
className={focused ? 'fake-input focus' : 'fake-input'}
className={fakeInputCls}
ref="input-container"
onClick={preventKeyboard ? () => {} : this.onFakeInputClick}
>
Expand Down
3 changes: 3 additions & 0 deletions components/input-item/style/CustomKeyboard.less
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
text-align: right;
color: #000;
font-size: 34px;
&.fake-input-disabled {
color: @color-text-disabled;
}

&.focus {
transition: color .2s;
Expand Down

0 comments on commit 4dd715a

Please sign in to comment.