Skip to content

Commit 3eca602

Browse files
authoredNov 29, 2019
fix(ui5-datepicker): it is now possible to set an empty placeholder (#997)
1 parent 44d6c27 commit 3eca602

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed
 

‎packages/base/src/UI5Element.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ class UI5Element extends HTMLElement {
636636
} else if (propType === Object) {
637637
defaultState[propName] = "defaultValue" in props[propName] ? props[propName].defaultValue : {};
638638
} else if (propType === String) {
639-
defaultState[propName] = propDefaultValue || "";
639+
defaultState[propName] = "defaultValue" in props[propName] ? props[propName].defaultValue : "";
640640
} else {
641641
defaultState[propName] = propDefaultValue;
642642
}
@@ -678,7 +678,7 @@ class UI5Element extends HTMLElement {
678678
if (propData.type === Boolean) {
679679
return false;
680680
} else if (propData.type === String) { // eslint-disable-line
681-
return propDefaultValue || "";
681+
return propDefaultValue;
682682
} else if (propData.multiple) { // eslint-disable-line
683683
return [];
684684
} else {

‎packages/main/src/DatePicker.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,15 @@ const metadata = {
112112
* <code>ui5-datepicker</code> has no value.
113113
*
114114
* <b>Note:</b> When no placeholder is set, the format pattern is displayed as a placeholder.
115+
* Passing an empty string as the value of this property will make the <code>ui5-datepicker</code> appear empty - without placeholder or format pattern.
116+
*
115117
* @type {string}
116-
* @defaultvalue ""
118+
* @defaultvalue undefined
117119
* @public
118120
*/
119121
placeholder: {
120122
type: String,
123+
defaultValue: undefined,
121124
},
122125

123126
/**
@@ -391,7 +394,7 @@ class DatePicker extends UI5Element {
391394
}
392395

393396
get _placeholder() {
394-
return this.placeholder || this._displayFormat;
397+
return this.placeholder !== undefined ? this.placeholder : this._displayFormat;
395398
}
396399

397400
getFormat() {

‎packages/main/test/pages/DatePicker.html

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ <h3>buddhist calendar type</h3>
7878

7979
<h3>japanese calendar type</h3>
8080
<ui5-datepicker primary-calendar-type='Japanese'></ui5-datepicker>
81+
82+
<h3>explicitly set empty placeholder</h3>
83+
<ui5-datepicker placeholder=""></ui5-datepicker>
8184
</div>
8285
<script>
8386
var dp = document.getElementById('dp5');

0 commit comments

Comments
 (0)
Please sign in to comment.