Skip to content

Commit a25a3a5

Browse files
committed
ACP2E-188: Reworked on fixes
1 parent 2457ecd commit a25a3a5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/datepicker.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ define([
2828
* For more info about options take a look at "mage/calendar" and jquery.ui.datepicker widget.
2929
* @param {HTMLElement} el - Element, that binding is applied to
3030
* @param {Function} valueAccessor - Function that returns value, passed to binding
31+
* @param {object} allBindings
32+
* @param {object} viewModel
33+
* @param {object} bindingContext
3134
*/
32-
init: function (el, valueAccessor) {
35+
init: function (el, valueAccessor, allBindings, viewModel, bindingContext) {
3336
var config = valueAccessor(),
3437
observable,
3538
options = {};
@@ -50,6 +53,15 @@ define([
5053
observable(this.value);
5154
});
5255
});
56+
57+
// Binding context value can be cleared by another component (such
58+
// as filters), make sure datepicker element value is cleared, too.
59+
bindingContext.$data.value.subscribe(function (newVal) {
60+
if (!newVal) {
61+
$(el).val('');
62+
}
63+
}, this);
64+
5365
},
5466

5567
/**

app/code/Magento/Ui/view/base/web/templates/form/element/date.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
hasFocus: focused,
99
datepicker: { storage: shiftedValue, options: options },
1010
valueUpdate: valueUpdate,
11-
value: shiftedValue,
1211
attr: {
12+
value: shiftedValue,
1313
name: inputName,
1414
placeholder: placeholder,
1515
'aria-describedby': noticeId,

0 commit comments

Comments
 (0)