Permalink
Browse files

fix(datetime): Fix floating label with empty ion-datetime (#11552)

Fixes #11547
  • Loading branch information...
imgx64 authored and manucorporat committed May 8, 2017
1 parent 5fbca0e commit 5a895bb099bb559059bd9950f010d07d796dd5a1
@@ -8,7 +8,7 @@ import { PickerColumn } from '../picker/picker-options';
import { Form } from '../../util/form';
import { BaseInput } from '../../util/base-input';
import { Item } from '../item/item';
import { deepCopy, isBlank, isPresent, isArray, isString, assert, clamp } from '../../util/util';
import { deepCopy, isBlank, isPresent, isArray, isObject, isString, assert, clamp } from '../../util/util';
import { dateValueRange, renderDateTime, renderTextFormat, convertDataToISO, convertFormatToKey, getValueFromFormat, parseTemplate, parseDate, updateDate, DateTimeData, daysInMonth, dateSortValue, dateDataSortValue, LocaleData } from '../../util/datetime-util';
/**
@@ -760,6 +760,16 @@ export class DateTime extends BaseInput<DateTimeData> implements AfterContentIni
return this._value;
}
/**
* @hidden
*/
hasValue(): boolean {
const val = this._value;
return isPresent(val)
&& isObject(val)
&& Object.keys(val).length > 0;
}
/**
* @hidden
*/
@@ -658,6 +658,20 @@ describe('DateTime', () => {
});
describe('hasValue', () => {
it('should return false if value is not set, and return true if value is set', zoned(() => {
expect(datetime.hasValue()).toEqual(false);
datetime.setValue('1994-12-15T13:47:20.789Z');
expect(datetime.hasValue()).toEqual(true);
datetime.setValue('');
expect(datetime.hasValue()).toEqual(false);
}));
});
var datetime: DateTime;
var picker: Picker;
@@ -29,6 +29,11 @@
<ion-datetime displayFormat="D MMM YYYY" [(ngModel)]="floating2"></ion-datetime>
</ion-item>
<ion-item>
<ion-label floating>Floating</ion-label>
<ion-datetime [(ngModel)]="floating3"></ion-datetime>
</ion-item>
<ion-item>
<ion-label fixed>Fixed</ion-label>
<ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="fixed1"></ion-datetime>
@@ -9,6 +9,7 @@ export class RootPage {
stacked2 = '1994-12-15T13:47:20.789';
floating1 = '1995-04-15';
floating2 = '1995-04-15';
floating3 = '';
fixed1 = '2002-09-23T15:03:46.789';
fixed2 = '2002-09-23T15:03:46.789';
inline1 = '2005-06-17T11:06Z';

0 comments on commit 5a895bb

Please sign in to comment.