Hi,
We're encountering some inconsistent behavior when editing the task duration in the duration column. Specifically, we're trying to round the duration value when the unit is set to hours, as we don't want to allow decimal precision in this case.
Our approach has been to listen to the focusOut event of the durationField editor and round the value if the conditions are met. However, the solution works as expected intermittently—sometimes it rounds correctly, but other times it doesn't.
This is the piece of code we used:
{
id: 'duration', type: 'duration', editor: new DurationField({
allowedUnits: 'hour,day,week,month,quarter,year',
listeners: {
focusOut: (eventData) => {
const durationField = (eventData.source as any);
const durationFieldValue = durationField.value;
if (durationFieldValue.unit === 'hour' && !Number.isInteger(durationFieldValue.magnitude)) {
durationFieldValue.magnitude = Math.round(durationFieldValue.magnitude);
}
}
}
})
},
And also here's a video demonstrating the issue:
Is this the right approach to do something like this? Or are we doing something wrong?
We also tried changing the task duration, instead of the durationField magnitude, but it didn't seem to solve the issue.
Thank you, Luca.