Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-date-picker): setting value before firing event #3629

Merged
merged 2 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion packages/main/src/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ class DatePicker extends DateComponentBase {
}

let executeEvent = true;
const previousValue = this.value;
if (updateValue) {
this.value = value;
}

events.forEach(event => {
if (!this.fireEvent(event, { value, valid }, true)) {
Expand All @@ -521,11 +525,11 @@ class DatePicker extends DateComponentBase {
});

if (!executeEvent) {
this.value = previousValue;
return;
}

if (updateValue) {
this.value = value;
this._updateValueState(); // Change the value state to Error/None, but only if needed
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/main/test/pages/DatePicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ <h3>DatePicker with properties given in the wrong format</h3>

dp.addEventListener('ui5-change', function(e) {
console.log('change: ', e.detail);
debugger;
labelChange.innerHTML = 'change: ' + JSON.stringify(e.detail);
});
dp.addEventListener('ui5-input', function(e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/test/pages/DatePicker_test_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h3>Test accessibleName and accessibleNameRef</h3>
document.querySelector("#dp8").addEventListener("ui5-change", increaseCounter);
document.querySelector("#dp13").addEventListener("ui5-change", function(e) {
document.querySelector('#lblTomorrow').innerHTML = ++counterTomorrow;
document.querySelector('#lblTomorrowDate').innerHTML = e.detail.value;
document.querySelector('#lblTomorrowDate').innerHTML = e.target.value;
});

var dp16 = document.getElementById('dp16');
Expand Down