Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/panels/TimePanel/TimeBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions tests/picker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<MomentPicker picker="time" {...props} />);
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(<MomentPicker picker="time" hourStep={-1} />);
wrapper.openPicker();
expect(wrapper.find('.rc-picker-time-panel-column').at(0).children()).toHaveLength(24);
});
});

it('pass data- & aria- & role', () => {
Expand Down