Skip to content

Commit

Permalink
Fix #5998: fixed minute values updated by hour changes with stepMinute (
Browse files Browse the repository at this point in the history
#6217)

Co-authored-by: Shubham Saurabh <[email protected]>
  • Loading branch information
shubhsaur and Shubham Saurabh authored Mar 25, 2024
1 parent dda958b commit ca69190
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@ export const Calendar = React.memo(
}
};

const roundMinutesToStep = (minutes) => {
if (props.stepMinute) {
return Math.round(minutes / props.stepMinute) * props.stepMinute;
}

return minutes;
};

const incrementHour = (event) => {
const currentTime = getCurrentDateTime();
const currentHour = currentTime.getHours();
Expand Down Expand Up @@ -606,10 +614,10 @@ export const Calendar = React.memo(
updateTime(event, newHour, props.maxDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
}
} else {
updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
updateTime(event, newHour, roundMinutesToStep(currentTime.getMinutes()), currentTime.getSeconds(), currentTime.getMilliseconds());
}
} else {
updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
updateTime(event, newHour, roundMinutesToStep(currentTime.getMinutes()), currentTime.getSeconds(), currentTime.getMilliseconds());
}
}

Expand Down Expand Up @@ -646,10 +654,10 @@ export const Calendar = React.memo(
updateTime(event, newHour, props.minDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
}
} else {
updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
updateTime(event, newHour, roundMinutesToStep(currentTime.getMinutes()), currentTime.getSeconds(), currentTime.getMilliseconds());
}
} else {
updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
updateTime(event, newHour, roundMinutesToStep(currentTime.getMinutes()), currentTime.getSeconds(), currentTime.getMilliseconds());
}
}

Expand Down

0 comments on commit ca69190

Please sign in to comment.