Skip to content

Commit

Permalink
Fix money input (ant-design#1463)
Browse files Browse the repository at this point in the history
* fix issue ant-design#1437 money input support disabled

* fix tslint error

* fix issue ant-design#1437 money input support disabled

* fix tslint error

* improve style for inputitem

* improve inputitem when type is money
  • Loading branch information
pingan1927 authored and lixiaoyang1992 committed Apr 26, 2018
1 parent 1be9791 commit ed43762
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 13 additions & 4 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,8 @@ class NumberInput extends React.Component<any, any> {
onBlur: () => {},
placeholder: '',
value: '',
disabled: false,
editable: true,
prefixCls: 'am-input',
keyboardPrefixCls: 'am-number-keyboard',
};
Expand All @@ -25,16 +28,17 @@ class NumberInput extends React.Component<any, any> {
componentWillReceiveProps(nextProps) {
if ('focused' in nextProps && nextProps.focused !== this.state.focused) {
this.debounceFocusTimeout = setTimeout(() => {
if (nextProps.focused) {
const { disabled, editable } = this.props;
if (nextProps.focused && !disabled && editable) {
this.onInputFocus(this.props.value);
}
}, 10);
}
}

componentDidMount() {
const { autoFocus, focused, value } = this.props;
if (autoFocus || focused) {
const { autoFocus, focused, value, disabled, editable } = this.props;
if ((autoFocus || focused) && !disabled && editable ) {
this.onInputFocus(value);
}
document.addEventListener('click', this._blurEventListener, false);
Expand Down Expand Up @@ -105,10 +109,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`]: disabled,
});
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
4 changes: 4 additions & 0 deletions components/input-item/style/CustomKeyboard.less
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
color: #000;
font-size: 34px;

&.fake-input-disabled {
color: @color-text-disabled;
}

&.focus {
transition: color .2s;

Expand Down

0 comments on commit ed43762

Please sign in to comment.