vaadin/vaadin-date-picker

change event should include the new value

rwestlund opened this issue · 2 comments

Expected outcome

The change event should include the new date value as e.detail.

Actual outcome

e.detail is null.

Version

vaadin-date-picker 3.3.2
polymer 2.6.0

This would make the change event vastly more useful, and enable a one-way data binding dataflow. change also seems to fire before value is updated, making the event somewhat useless, as the handler can't get the new value from the property either.

change events on native <input>s don't have a detail either, but the order of execution should be so that the new value is already available via the value property when the change event is dispatched.

And the order does seem to be as it should. I tested this on vaadin-date-picker v3.3.2 (the version mentioned in issue description) and v4.0.0 (latest release) using Chrome 74 and Safari 12.1 on macOS. In both of those versions the change event seems to be correctly sent after the value property has been set so you can access the new value e.g. via event.currentTarget.value from the event listener.

You can use a simple event listener like this to test it:

myDatePicker.addEventListener('change', e => console.log(e.currentTarget.value));

And you will see the new value being logged to console every time you change the value.

Adding the event.detail.value to this event is not an API we want to add now since it doesn't match the behaviour of the native change event and you can already get the same information easily via event.currentTarget.value. Closing this issue ("change event should include the new value") as "won't fix".

But if you can show how to reproduce the problem that change event would be dispatched before the value property has been updated (which would be a bug), then please open a new issue about that including more info on how to reproduce it (and with which browser).