Skip to content

Commit

Permalink
Show empty input with single null value
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Johnson committed Jul 23, 2018
1 parent 06c0de8 commit 174c306
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/src/_shared/DateTextField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ const getDisplayDate = (props) => {
} = props;
const value = utils.ensureArray(props.value);

const isEmpty = value.length < 1;
const date = value.map(utils.date);
const isEmpty = value == null || value.length < 1 || (value.length == 1 && value[0] == null);

if (labelFunc) {
return labelFunc(isEmpty ? null : date, invalidLabel);
}
const date = value.map(utils.date);

if (isEmpty) {
return emptyLabel;
}

if (labelFunc) {
return labelFunc(date, invalidLabel);
}

return date.every(utils.isValid)
? date.map(o => utils.format(o, format)).join(formatSeperator)
: invalidLabel;
Expand Down

0 comments on commit 174c306

Please sign in to comment.