diff --git a/src/panels/TimePanel/TimeBody.tsx b/src/panels/TimePanel/TimeBody.tsx
index 186182a4e..5a9f7c9da 100644
--- a/src/panels/TimePanel/TimeBody.tsx
+++ b/src/panels/TimePanel/TimeBody.tsx
@@ -24,7 +24,8 @@ function generateUnits(
disabledUnits: number[] | undefined,
) {
const units: Unit[] = [];
- for (let i = start; i <= end; i += step) {
+ const integerStep = step >= 1 ? step | 0 : 1;
+ for (let i = start; i <= end; i += integerStep) {
units.push({
label: leftPad(i, 2),
value: i,
diff --git a/tests/picker.spec.tsx b/tests/picker.spec.tsx
index d044b1536..6905e0882 100644
--- a/tests/picker.spec.tsx
+++ b/tests/picker.spec.tsx
@@ -581,6 +581,29 @@ describe('Picker.Basic', () => {
);
spy.mockRestore();
});
+
+ // https://github.com/ant-design/ant-design/issues/40914
+ ['hour', 'minute', 'second'].forEach((unit, index) => {
+ it(`should show integer when step is not integer (${unit})`, () => {
+ const props = {
+ [`${unit}Step`]: 5.5,
+ };
+ const wrapper = mount();
+ wrapper.openPicker();
+
+ const column = wrapper.find('.rc-picker-time-panel-column').at(index);
+ const cells = column.find('.rc-picker-time-panel-cell-inner');
+ cells.forEach((cell) => {
+ expect(Number.isInteger(Number(cell.text()))).toBeTruthy();
+ });
+ });
+ });
+
+ it('should work when hourStep < 0', () => {
+ const wrapper = mount();
+ wrapper.openPicker();
+ expect(wrapper.find('.rc-picker-time-panel-column').at(0).children()).toHaveLength(24);
+ });
});
it('pass data- & aria- & role', () => {