Value change event with userOriginated true is sent when a DateTime is truncated
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
In Vaadin 8.11, when you fill a DateTimeField with a LocaleDateTime a event is sent with userOriginated=true.
The behavior is not expected as the user didn't do any changes.
Here is the code to reproduce it:
DateTimeField date = new DateTimeField("Date");
date.setResolution(DateTimeResolution.SECOND);
// don't throw value change listener
//date.setValue(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS));
// will throw a value change listener
date.setValue(LocalDateTime.now());
System.out.println(date.getValue());
date.addValueChangeListener(event -> {
if (event.isUserOriginated()) {
System.out.println("From user " + event.getValue());
} else {
System.out.println("NOT From user " + event.getValue());
}
});
To avoid this value change event, you can truncate the value with the same resolution (here in second).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior with the DateTimeField snippet, using a value whose precision exceeds the configured SECOND resolution. Then inspect the DateTimeField value-change handling; done means truncation during programmatic setValue does not produce a value-change event marked userOriginated=true.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100