mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 02:59:04 +08:00
Fix calendar internal select source type (#42459)
* fix: pass panelMode as source type to internal select trigger * test: add test case for triggering select source with panelMode * test: update test to pass correct value to check * test: fix passing value to test * test: update test in proper select.test file * test: update test case --------- Co-authored-by: 二货机器人 <smith3816@gmail.com>
This commit is contained in:
parent
c1dbcae764
commit
5bbd13d2c8
@ -85,11 +85,15 @@ describe('Calendar.onSelect', () => {
|
||||
const onPanelChange = jest.fn();
|
||||
const { container } = render(<Calendar onSelect={onSelect} onPanelChange={onPanelChange} />);
|
||||
|
||||
// Default is month radio
|
||||
fireEvent.click(container.querySelector('.ant-picker-cell')!);
|
||||
expect(onSelect).toHaveBeenCalledWith(expect.anything(), { source: 'date' });
|
||||
|
||||
// Click year radio
|
||||
fireEvent.click(container.querySelectorAll('.ant-radio-button-input')[1]!);
|
||||
expect(onPanelChange).toHaveBeenCalledWith(expect.anything(), 'year');
|
||||
|
||||
fireEvent.click(container.querySelector('.ant-picker-cell')!);
|
||||
expect(onSelect).toHaveBeenCalledWith(expect.anything(), { source: 'date' });
|
||||
expect(onSelect).toHaveBeenCalledWith(expect.anything(), { source: 'month' });
|
||||
});
|
||||
});
|
||||
|
@ -339,7 +339,7 @@ function generateCalendar<DateType>(generateConfig: GenerateConfig<DateType>) {
|
||||
generateConfig={generateConfig}
|
||||
cellRender={mergedCellRender}
|
||||
onSelect={(nextDate) => {
|
||||
onInternalSelect(nextDate, 'date');
|
||||
onInternalSelect(nextDate, panelMode);
|
||||
}}
|
||||
mode={panelMode}
|
||||
picker={panelMode}
|
||||
|
Loading…
Reference in New Issue
Block a user