Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/components/field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -63,6 +66,7 @@ export default class TextField extends PureComponent {
disabledLineType: 'dotted',

disabled: false,
disableLabelAnimation: false,
};

static propTypes = {
Expand Down Expand Up @@ -108,6 +112,7 @@ export default class TextField extends PureComponent {
disabledLineType: Line.propTypes.lineType,

disabled: PropTypes.bool,
disableLabelAnimation: PropTypes.bool,

formatText: PropTypes.func,

Expand Down