diff --git a/readme.md b/readme.md index 4083fb2f..99f3b05d 100644 --- a/readme.md +++ b/readme.md @@ -102,6 +102,7 @@ class Example extends Component { lineType | Text field line type | String | solid disabledLineType | Text field line type in disabled state | String | dotted animationDuration | Text field animation duration in ms | Number | 225 + disableLabelAnimation | Keep label in floating state | Boolean | false characterRestriction | Text field soft limit for character counter | Number | - disabled | Text field availability | Boolean | false editable | Text field text can be edited | Boolean | true diff --git a/src/components/field/index.js b/src/components/field/index.js index 281b7451..f0bf9c59 100644 --- a/src/components/field/index.js +++ b/src/components/field/index.js @@ -25,9 +25,12 @@ function startAnimation(animation, options, callback) { } function labelStateFromProps(props, state) { - let { placeholder, defaultValue } = props; + let { placeholder, defaultValue, disableLabelAnimation } = props; let { text, receivedFocus } = state; + if (disableLabelAnimation) { + return true; + } return !!(placeholder || text || (!receivedFocus && defaultValue)); } @@ -63,6 +66,7 @@ export default class TextField extends PureComponent { disabledLineType: 'dotted', disabled: false, + disableLabelAnimation: false, }; static propTypes = { @@ -108,6 +112,7 @@ export default class TextField extends PureComponent { disabledLineType: Line.propTypes.lineType, disabled: PropTypes.bool, + disableLabelAnimation: PropTypes.bool, formatText: PropTypes.func,