diff --git a/src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsx b/src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsx index 8df13c40e..33544bca6 100644 --- a/src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsx +++ b/src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsx @@ -54,7 +54,7 @@ export default function TimeColumn(props: TimeUnitColum stopScroll(); clearDelayCheck(); }; - }, [value, optionalValue, units]); + }, [value, optionalValue, units.join(',')]); // ========================= Change ========================= // Scroll event if sync onScroll diff --git a/tests/picker.spec.tsx b/tests/picker.spec.tsx index 227b31172..066eb5e05 100644 --- a/tests/picker.spec.tsx +++ b/tests/picker.spec.tsx @@ -292,9 +292,7 @@ describe('Picker.Basic', () => { // https://github.com/ant-design/ant-design/issues/49400 it('should not throw errow when input end year first', () => { - const { container } = render( - , - ); + const { container } = render(); openPicker(container); fireEvent.focus(container.querySelectorAll('input')[1]); expect(() => { @@ -369,7 +367,7 @@ describe('Picker.Basic', () => { it('pass tabIndex', () => { const { container } = render(
- +
, ); @@ -583,12 +581,7 @@ describe('Picker.Basic', () => { }); it('prefix', () => { - render( - } - allowClear - />, - ); + render(} allowClear />); expect(document.querySelector('.prefix')).toBeInTheDocument(); }); @@ -1064,6 +1057,10 @@ describe('Picker.Basic', () => { }); }); + beforeEach(() => { + triggered = false; + }); + afterAll(() => { domMock.mockRestore(); }); @@ -1083,6 +1080,46 @@ describe('Picker.Basic', () => { jest.useRealTimers(); unmount(); }); + + it('not repeat scroll if disabledTime return same value', () => { + const getDisabledTimeFn = () => () => ({ + disabledHours: () => [10], + disabledMinutes: () => [10], + disabledSeconds: () => [10], + }); + + const { rerender } = render( + , + ); + + act(() => { + jest.advanceTimersByTime(1000); + jest.clearAllTimers(); + }); + expect(triggered).toBeTruthy(); + + // New disabledTime + triggered = false; + rerender( + , + ); + + act(() => { + jest.advanceTimersByTime(1000); + jest.clearAllTimers(); + }); + expect(triggered).toBeFalsy(); + }); }); describe('prevent default on keydown', () => {